PHP Gets the current directory location method, PHP gets the current
This example describes how PHP obtains the current directory location. Share to everyone for your reference. The specific analysis is as follows:
If you want to get the directory of the script file, use the function getcwd () to implement it. The function declaration is as follows:
String getcwd (void);
The current directory string is returned after successful execution, and the failure returns false.
Examples are as follows:
The following will use the GETCWD () function to get the directory for the script file. The code is as follows:
Copy the Code code as follows: $shili = GETCWD (); Get the current script directory
$i = 0;
if (Is_dir ($shili)) {//detect is a legitimate directory
if ($shi = Opendir ($shili)) {//Open Directory
while ($li = Readdir ($shi)) {//Read directory
$i + +;
echo "$i: $li"; }}}//content in the output directory
?>
The result of the operation is as shown.
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/917677.html www.bkjia.com true http://www.bkjia.com/PHPjc/917677.html techarticle PHP gets The current directory location method, PHP Gets the current instance of this article tells the way PHP gets the current directory location. Share to everyone for your reference. The specific analysis is as follows ...