Set_include_path (Get_include_path (). p_s. '.' . p_s. $siteConf [' BaseDir ']);
Set_include_path (Get_include_path (). p_s. '.' . p_s. $siteConf [' Libdir ']);
Set_include_path (Get_include_path (). p_s. '.' . p_s. $siteConf [' BaseDir ']. ' app ');
Code as above, p_s is Path_separator
Problem:
Why do I have to add '. ' Before each path? What about this one?
I checked the manual, there is one in the comments, which means it is necessary to add it, but the reason is still unknown ....
Joel at pittet Dot ca17-nov-2010 02:46
Seems Set_include_path wasn ' t working for me.
The problem was I didn ' t has.: In my Include_path
Which seemed to stop the Set_include_path ().
Reply content:
Set_include_path (Get_include_path (). p_s. '.' . p_s. $siteConf [' BaseDir ']);
Set_include_path (Get_include_path (). p_s. '.' . p_s. $siteConf [' Libdir ']);
Set_include_path (Get_include_path (). p_s. '.' . p_s. $siteConf [' BaseDir ']. ' app ');
Code as above, p_s is Path_separator
Problem:
Why do I have to add '. ' Before each path? What about this one?
I checked the manual, there is one in the comments, which means it is necessary to add it, but the reason is still unknown ....
Joel at pittet Dot ca17-nov-2010 02:46
Seems Set_include_path wasn ' t working for me.
The problem was I didn ' t has.: In my Include_path
Which seemed to stop the Set_include_path ().
"." Represents the current directory, ":" is a delimiter of two different include path values.
Include_path does not contain ".", PHP encounters an include ($file), require ($file) statement when it is not in the current directory (if you are accessing/var/www/html/my_app/ index.php, the current directory is/www/html/my_app/) looking for $file, go directly to other include_path search.
Include_path "." To see if you will not use relative paths to include files in the current directory, the PHP engine is not forced.
Real-Machine testing
Tests have shown that either the INI or the code set_include_path () can be changed without the "."
Figure 1:ini Setting the Include_path
Include_path is not set in Figure 2:ini, Set_include_path () is called in the code
Figure 3:ini Setting include_path, calling Set_include_path () in the code
Figure 4:ini Setting Include_path (containing the current directory), calling Set_include_path () in the code
In addition, if the code does not call Set_include_path (), the INI does not set the include_path, the direct echo get_ include_path (), will output "."
Also, the first time the test, first Set_include_path ("/var"), and then Echo Get_include_path (), incredibly nothing output, but I can no longer reproduce this phenomenon, Not sure if test.php belonged to root with sudo (theoretically not, but failed to reproduce)
Extended Reading
For more details on the include, you can read an article I wrote in the previous two weeks, "About PHP class library auto-loading": http://weibo.com/1779910713/zg59ehZCd, Page Two, the first paragraph.
The goods are estimated to be direct set_include_path ("/some/path"); So there was an error in the include (file under the current directory).
This is similar to executing files under the current directory under Linux./error.
If you use Get_include_path () to spell it, you don't need it. You can echo the value of Get_include_path () and see that it contains the "."