How to get the current directory location in PHP, php gets the current location_PHP tutorial

WBOY
Release: 2016-07-13 10:12:55
Original
1210 people have browsed it

How to get the current directory location in PHP, php gets the current location

The example in this article describes how PHP obtains the current directory location. Share it with everyone for your reference. The specific analysis is as follows:

If you want to get the directory of the script file, you need to use the function getcwd() to achieve it. The function declaration is as follows:

string getcwd ( void ) ;

Returns the current directory string after successful execution, otherwise returns FALSE.

An example is as follows:

The getcwd() function will be used below to obtain the directory of the script file. The code is as follows:

Copy code The code is as follows:
$shili= getcwd () ; //Get the current script directory
$i = 0;
if ( is_dir ( $shili )){                                                                                                           If ($shi = opendir ($shili)){ //Open directory
while ($li = readdir( $shi )){ //Read directory
$i++ ;
echo " $i: $li" ; } } } // Output the contents of the directory
?>
The running results are shown in the figure below.

I hope this article will be helpful to everyone’s PHP programming design.

http://www.bkjia.com/PHPjc/917677.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/917677.htmlTechArticleHow to get the current directory location in PHP, php gets the current directory location. This article describes how PHP gets the current directory location. method. Share it with everyone for your reference. The specific analysis is as follows...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template