$ _ SERVER ['path'] value. I have two files: phpinfo. php and only & nbsp; PHPcode & lt ;? Phpinfo ();? & Gt; the other file is test. php, which only contains PHPcode & lt ;? Echo $ _ SERVER ['path'];? & Gt $ _ SERVER ['path'] value
Hello everyone.
I have two files, one of which is phpinfo. php and only
PHP code
Another file is test. php, which contains only
PHP code
Under the command line, I use the User/Group username on the phpinfo page to log in.
Run php test. php
The output path and the path output by running http: // localhost/test. php in the browser
Content consistency. Does anyone know why?
It is clearly the same user name that is executed in the command line, and the same user name is executed in the webpage.
The difference is that there is no such thing through apache, but I also use the username in httpd. conf of apache.
Why are the output paths inconsistent.
Please take a look. thank you !!
------ Solution --------------------
$ _ SERVER ['path']
Is the PATH value of the operating system environment variable. the same machine is naturally the same
------ Solution --------------------
I don't understand. the user/group in phpinfo indicates the valid user ID and valid user group ID of apache running?
Oh.
One is apache access, and the other is cut into apache users and executed in Php, right?
Of course, it is different because apache is root-enabled to bind port 80. the root user's PATH contains the sbin PATH. after binding port 80, it is split into user/group, however, you need to know that the environment variables are inherited from the shell, while the shell environment variables are determined by the user who starts the apache process, and the user who starts apache is root, the root shell process environment variable contains sbin, so the started apache process inherits the shell environment variable and also contains sbin. after bind in apache, setuid will not change the process environment variable.
The reason for executing php directly with user/group is obvious. The shell process of common users does not have the PATH of sbin, so the php interpreter process does not have the PATH environment variable of sbin.
------ Solution --------------------
"PATH_TRANSLATED"
The basic path of the file system (not the document root directory) where the current script is located. This is the result of a virtual image to a real path on the server.
Note: After PHP 4.3.2, PATH_TRANSLATED does not implicitly assign values like Apache 1 in Apache 2 SAPI mode. If Apache does not generate this value, PHP generates and puts the value in the SCRIPT_FILENAME server constant. This modification complies with CGI specifications. PATH_TRANSLATED exists only under the conditions defined by PATH_INFO.
Apache 2 users can use AcceptPathInfo On in httpd. conf to define PATH_INFO.