In some PHP, the ENVIRONMENT constant can be defined to distinguish the development ENVIRONMENT from the production ENVIRONMENT, for example:
Define ('enable', isset ($ _ SERVER ['ci _ env'])? $ _ SERVER ['ci _ env']: 'development ');
Switch (ENVIRONMENT)
{
Case 'development ':
Error_reporting (-1 );
Ini_set ('display _ errors ', 1 );
Break;
Case 'testing ':
Case 'production ':
Ini_set ('display _ errors ', 0 );
If (version_compare (PHP_VERSION, '5. 3', '> = '))
{
Error_reporting (E_ALL &~ E_NOTICE &~ E_DEPRECATED &~ E_STRICT &~ E_USER_NOTICE &~ E_USER_DEPRECATED );
}
Else
{
Error_reporting (E_ALL &~ E_NOTICE &~ E_STRICT &~ E_USER_NOTICE );
}
Break;
Default:
Header ('http/1.1 503 Service Unavailable. ', TRUE, 503 );
Echo 'The application environment is not set correctly .';
Exit (1); // EXIT_ERROR
}
Here, $ _ SERVER ['ci _ env'] is defined in where?
Nginx configuration settings $ _ SERVER variables
Open an nginx website configuration:
Location ~ \. Php $ {
Try_files $ uri = 404;
Root/usr/share/nginx/html/tanteng. me/public;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Fastcgi_param MYENV 'dev ';
Include fastcgi_params;
}
Fastcgi_param MYENV 'dev' is the newly added statement.
Print $ _ SERVER in PHP:
......
"SERVER_ADDR" => "192.168.10.31"
"SERVER_NAME" => "www. tanteng. me"
"SERVER_PORT" => "80"
"SERVER_SOFTWARE" => "nginx/1.9.11"
"SERVER_PROTOCOL" => "HTTP/1.1"
"SERVER_ADMIN" => ""
"SERVER_SIGNATURE" => ""
"SCRIPT_NAME" => "/index. php"
"REDIRECT_STATUS" => "200"
"REQUEST_URI" => "/test/redis"
& Quot; REMOTE_PORT & quot; = & gt; 61290
"DOCUMENT_URI" => "/index. php"
"REQUEST_METHOD" => "GET"
"REMOTE_ADDR" => "192.168.10.1"
"CONTENT_TYPE" => ""
"DOCUMENT_ROOT" => "/usr/share/nginx/html/tanteng. me/public"
"MYENV" => "DEV"
"CONTENT_LENGTH" => ""
"QUERY_STRING" => ""
"SCRIPT_FILENAME" => "/usr/share/nginx/html/tanteng. me/public/index. php"
"SCRIPT_URL" => "/index. php"
"SCRIPT_URI" => http://www.111cn.net
"PHP_SELF" => "/index. php"
......
In this way, we can see an extra variable named "MYENV.