File_get_contents () this is index. phpPHPcode & lt ;? Php $ file. test. php; $ contentfile_get_contents ($ file); echo $ content; then test. in php, the two thisisatest files are located in the same level Directory. when I run them in a browser, thisis file_get_contents ()
This is index. php.
PHP code
Then in test. php, there is one sentence: this is a test
These two files are located in the same level Directory. when I run the 'This is a test' statement in a browser, it will be normally typed out, but a warning will appear when I run the command line, no output 'This is a test '.
The error is as follows:
C: \ Users \ hahaliu> php G: \ www \ index. php
PHP Warning: file_get_contents (test. php): failed to open stream: No such file
Or directory in G: \ www \ index. php on line 3
Warning: file_get_contents (test. php): failed to open stream: No such file or di
Rectory in G: \ www \ index. php on line 3
Then I changed $ file to an absolute path.
$ File = 'G:/www/test. php ';
The command line can output 'This is a test'. why is an error in the command line with a relative path? I am very confused. Is it true that nothing is set?
------ Solution --------------------
Without considering the parameter de_path in php. ini:
Browsing through a browser, that is, when browsing as a web server, the directory where files run is configured based on the web server.
The command line is based on the path of the system environment.
The following two outputs show the differences.
PHP code
echo getcwd();echo ini_get('include_path');