PHP Gets the current directory relative to the domain name, PHP gets the current directory
This article reproduced from:??? Http:[email protected]/blog/static/166335404201122322635868/
?
?
http://127.0.0.1/dev/classd/index.php/download
For example, this address, I want to get the address of the red zone for the link within the generated station, named BaseURL.
With $_server[' Script_name '), $_server[' Script_name ' is the relative path of the PHP file that is currently being accessed, as long as it is handled as follows:
//Get the directory part from $_server[' Script_name '] and replace the backslash problem that may occur with the DirName function ??
$BASEURL ?=? Str_replace (' \ \ ', '/', dirname ($_server['script_name'));
//Guaranteed to be empty when can return the normal value that can be used ?
$baseUrl? =?empty ($BASEURL)??? ' / '?:?' / '. Trim ($BASEURL, '/'). ' /';??
This will normally get to the directory address of the /dev/classd/ section.
By the way, the Zend Framework of the BASEURL () function, the results of a look at a lot of code will not continue to see, I can not think of the same function he used a lot of code, from the $_server to get a bunch, and then the middle through two or three classes, Four or five methods to finally be called directly by us, in addition to the middle of three lines is to get the current PHP file, the others are useless and meaningless processing, ZF itself is already running slow enough, what is the meaning of it.
?
?
?
?
?