Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of $_ENV['APACHE_RUN_USER'] in PHP-CLI

Tags:

php

I'm running a PHP script from CLI interface.

How can I get the running user name like when I'm in Apache ( $_ENV['APACHE_RUN_USER'] )? At now I'm using exec('whoami'), but is not platform-indipendent.

Thanks.

like image 769
Fabio Mora Avatar asked Jan 13 '11 10:01

Fabio Mora


2 Answers

I had success with $_SERVER['LOGNAME']

like image 58
Brad B Avatar answered Oct 04 '22 01:10

Brad B


You could use $_ENV['USERNAME'] and it may be portable at least between Win and Linux

like image 41
Francesco Laurita Avatar answered Oct 04 '22 02:10

Francesco Laurita