Include file, is the relative path to the class or function an instantiated page or a file page?

Source: Internet
Author: User
a.php:: include "b.class.php";

Suppose that there is a relative path in the member method of b.class.php;
such as:./1.php __file__ and so on;

Will these relative paths be relative to the source file or relative to the a.php;

I use __file__ and./1.php test, unexpectedly is two kinds of effects, good chaos,

hereby ask; It is better to speak the principle in depth.


Reply to discussion (solution)

If you are in index.php include or require other files! Then the path in any other file is the path of index.php!

It can't be absolute!
__FILE__ is the location of the current file in the file system and is the absolute path. Not in the discussion of relative paths
The./1.php is a relative path, but the example you cite does not indicate the problem
If this a.php:: include "b/b.class.php";
So: this./1.php is relatively a.php, but/1.php does not exist and b/1.php exists, it is b/1.php.
Because b/1.php is also relative to b/b.php./1.php
This is a search order problem.

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