PHP Gets the current directory location method, PHP gets the current _php tutorial

Source: Internet
Author: User
Tags php programming

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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.