Doc #76957 [Opn]: Missing values in $_SERVER

From: Date: Tue, 02 Oct 2018 08:36:20 +0000
Subject: Doc #76957 [Opn]: Missing values in $_SERVER
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16039@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76957&edit=1 ID: 76957 User updated by: office at vargapeter dot net Reported by: office at vargapeter dot net Summary: Missing values in $_SERVER Status: Open Type: Documentation Problem Package: CGI/CLI related Operating System: Any Linux PHP Version: 7.2.10 Block user comment: N Private report: N New Comment: Sorry! I meant HOSTNAME not HOST. I apologize for the confusion! So HOSTNAME is missing. Previous Comments: ------------------------------------------------------------------------ [2018-10-02 08:32:42] office at vargapeter dot net Good question. How can I check it? ------------------------------------------------------------------------ [2018-10-01 19:08:40] requinix@php.net I don't believe PHP is creating a "HOST" value. Are you sure you aren't inheriting that from an exported environment variable? ------------------------------------------------------------------------ [2018-10-01 18:05:40] office at vargapeter dot net Description: ------------ 1) When executing 'php -c /path-to-ini-file /path/exec.php' via the system() function in the Apache module the script 'exec.php' doesn't have HOST value in $_SERVER. Running in the OS command line 'php -c /path-to-ini-file /path/exec.php' $_SERVER has HOST value. I consider it inconsistent for the HOST value which is in both cases known. 2) $_SERVER is more or less exactly the section Environment from phpinfo() function when running via system() in a browser tab. This behavior is nowhere documented and fairly surprising. Test script: --------------- foo.php - calling in a browser tab: <?php system("php -c /etc/php7/cli/php.ini /path/exec.php"); ?> exec.php - called a) via system() or directly from command line: <?php print_r($_SERVER); ?> Expected result: ---------------- From command line AND via system() in Browser tab: Array ( ... [HOST] => MY_HOST <---- MISSING [_] => /usr/bin/php [PHP_SELF] => /path/exec.php [SCRIPT_NAME] => /path/exec.php [SCRIPT_FILENAME] => /path/exec.php [PATH_TRANSLATED] => /path/exec.php [DOCUMENT_ROOT] => [REQUEST_TIME_FLOAT] => 1538415804.9271 [REQUEST_TIME] => 1538415804 [argv] => Array ( [0] => /path/exec.php ) [argc] => 1 ) Actual result: -------------- Totally different output; even running exec.php as PHP CLI version. No HOST entry. This is the output from system() in a browser tab: Array ( [APACHE_CONF_INCLUDE_FILES] => [mpm_found] => true [APACHE_CONF_INCLUDE_DIRS] => [SYSCONFIG_FILE] => /etc/sysconfig/apache2 [APACHE_START_TIMEOUT] => 2 [HTTPD_MODULE_IDS] => actions_module alias_module ... [APACHE_SERVERNAME] => [PATH] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin [APACHE_HTTPD_CONF] => [PWD] => /userdata/dev1/faewe.technology [APACHE_SERVERTOKENS] => ProductOnly [NOTIFY_SOCKET] => /run/systemd/notify [APACHE_SERVERADMIN] => [HTTPD_MODULE_PATHS] => /usr/lib64/apache2-prefork/mod_actions.so ... [SHLVL] => 1 [APACHE_ACCESS_LOG] => /var/log/apache2/access_log combined [LC_CTYPE] => en_US.UTF-8 [APACHE_LOGLEVEL] => warn [APACHE_USE_CANONICAL_NAME] => off [APACHE_EXTENDED_STATUS] => off [APACHE_MODULES] => actions ... php7 [APACHE_SERVER_FLAGS] => [HTTPD_MPM] => prefork [APACHE_SERVERSIGNATURE] => off [sysconfig_loaded] => true [APACHE_MPM] => [OLDPWD] => / [_] => /usr/bin/php [PHP_SELF] => /path/exec.php [SCRIPT_NAME] => /path/exec.php [SCRIPT_FILENAME] => /path/exec.php [PATH_TRANSLATED] => /path/exec.php [DOCUMENT_ROOT] => [REQUEST_TIME_FLOAT] => 1538415816.209 [REQUEST_TIME] => 1538415816 [argv] => Array ( [0] => /path/exec.php ) [argc] => 1 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76957&edit=1

« previous php.doc.bugs (#16039) next »