first:
Path commonly used in php
Current file path: D:phpwebphp_exampleinclude_path.php
Copy code The code is as follows :
1.dirname(__FILE__); //Output D:phpwebphp_example
2.$_SERVER['SCRIPT_FILENAME']; //Output D:/phpweb/php_example/include_path.php
second:
set_include_path in php
In php, when including a file, when the include path is neither relative nor absolute (such as: include( "example.php")), will first search the directory set by include_path, and then search in the current directory. This is why many materials mention that include("./example.php") is better than include("example.php" ) reasons for high efficiency.
Method:
1.ini_set("include_path", "/usr/lib/pear"); //All versions
2.set_include_path("/usr/lib/pear" "); //version>=4.3.0
You can use the following method to add a directory to the original directory
Copy the code The code is as follows:
$path = '/usr/lib/pear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);//The set include_path becomes Similar to /usr/lib/function;/usr/lib/pear
?>
http://www.bkjia.com/PHPjc/733053.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/733053.htmlTechArticlefirst: Commonly used paths in php Current file path: D:phpwebphp_exampleinclude_path.php Copy the code as follows: 1.dirname (__FILE__); //Output D:phpwebphp_example 2.$_SERVER['SC...