PHP Gets the current script directory GETCWD (), __file__

Source: Internet
Author: User

The path to get the current file today generally uses the following two functions.
GETCWD () function

GETCWD-Get Current working directory

Describe
String GETCWD (Invalid)
Gets the current working directory.

return value
Returns the success on the current working directory, or false failure.

In some Unix variants, GETCWD () will return False if any of the parent directories do not have a readable or search mode set, even in the current directory. See the way and the right to get more information with chmod ().

Instance

Example of # 1 GETCWD ()

DirName (__file__)

Pre-compilation and macro definitions, predefined constants, __file__. TEXT: __file__ The name of the current compiled program file

Let's look at an example.

<?php
Echo GETCWD (). "<br/>";
echo dirname (__file__);
?>

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.