here is the code:
putenv("LC_ALL=ru_RU.utf8");
print_r($_ENV) . PHP_EOL;
echo getenv('LC_ALL') . PHP_EOL;
I get following response:
Array (
[USER] => www-data
[HOME] => /var/www
[FCGI_ROLE] => RESPONDER
[QUERY_STRING] =>
[REQUEST_METHOD] => GET
[CONTENT_TYPE] =>
[CONTENT_LENGTH] =>
[SCRIPT_FILENAME] => /var/www/cms/public/index.php
[SCRIPT_NAME] => /index.php
[REQUEST_URI] => /backend/users
[DOCUMENT_URI] => /index.php
[DOCUMENT_ROOT] => /var/www/cms/public
[SERVER_PROTOCOL] => HTTP/1.1
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_SOFTWARE] => nginx/1.0.2
[REMOTE_ADDR] => 127.0.0.1
[REMOTE_PORT] => 48644
[SERVER_ADDR] => 127.0.0.1
[SERVER_PORT] => 80
[SERVER_NAME] => cmsdev.com
[REDIRECT_STATUS] => 200
[PATH_INFO] => /index.php
[HTTP_HOST] => cmsdev.com
[HTTP_USER_AGENT] => Mozilla/5.0 (
X11; Linux x86_64; rv:5.0
) Gecko/20100101 Firefox/5.0
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[HTTP_ACCEPT_LANGUAGE] => ru,en-us;q=0.7,en;q=0.3
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
[HTTP_CONNECTION] => keep-alive
[HTTP_COOKIE] => PHPSESSID=ipsldis425a3pitimet7uehaa7; locale=ru_RU; timezone=%7B%22name%22%3A%22UTC%2B0%22%2C%22offset%22%3A0%7D
[HTTP_CACHE_CONTROL] => max-age=0
)
ru_RU.utf8
So – it looks like instead of $_GET - it prints $_SERVER and it doesn’t contain LC_ALL. Any clues? (variables_order = "EGPCS").
It doesn’t print
$_SERVER, it print$_ENV. Environment variables are set the web server which is why you see then when you print$_ENV. As it says in the$_ENVdocumentation, it says:Those values are set when the script is first executed. When you call
setenv(), those values are not automatically added to$_ENV. You either have to add them manually or use thegetenv()function.This was also documented in the
putenvdocumentation comments.