PHP's Set_include_path function, is used to set the application directory, development projects when the rational application of this function, allows us to include without a layer of the calculation directory, but also to improve the efficiency of our development, reduce the file contains error rate
See an example
Create a new 2 php file, a directory location structure as follows
/index.php
/include/config.php
index.php Code:
<?php Set_include_path ("include"); Include ("config.php");?>
/include/config.php Code:
<?php Set_include_path ("include"); Include ("config.php");?>
Now we run the index.php how to see the results, we include only write config.php can be included in the/inlcude/config.php file.
When setting multiple include directories, use the ";" Number separate. such as: Set_include_path ("Include;include2;include3;lib;c:/php/lib"), you can use a relative path or a relative path. Perhaps this small code you may not feel the benefits of Set_include_path, but it does not matter, you just remember that such a code can achieve such a function, in your later technology, open the development of large projects do not forget to have such a function, he can reduce your workload.
The sister function Get_include_path () can get the include directory at that time, realize set_include_path the same function and our powerful and lovely Ini_set () Usage:
Ini_set (' include_path ', ' directory name ');