note 114048 deleted from reserved.variables.server by cmb

From: Date: Sun, 28 Jul 2019 08:03:47 +0000
Subject: note 114048 deleted from reserved.variables.server by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211712@lists.php.net to get a copy of this message
Note Submitter: info at salientdigital dot com ---- A word of caution... If you have some PHP code or file that is included from within a web request via Apache + PHP, as well as from a command line script, be very careful to inspect the keys inside of $_SERVER that you intend to use. The keys and values are different, and in fact, it also matters if you are running as your_user, sudo php from your_user, or from root. For example, I just found out that $_SERVER['PWD'] is not available if you run from the command line via sudo (PHP 5.2x, CentOS, YMMV). To make a test, create a file called server.php with the following content: <?php var_dump($_SERVER); ?> Then from the commandline: your_account/dir #$ php server.php > your_account_server.txt your_account/dir #$ sudo php server.php > your_account_sudo_server.txt your_account/dir #$ sudo bash root/dir #$ php server.php > root_server.txt Now you can diff the output of each of these three files and inspect against what you get when viewing the $_SERVER section of phpinfo() from a web request. You may find the differences to be quite striking, in all, four different ways to run the same PHP file!

« previous php.notes (#211712) next »