PHP contains file path related issues

Source: Internet
Author: User
PHP contains file path issues

??? Recently just learning PHP, in doing a small project, with a lot of require and include, by the absolute path, the relative path of the burn, finally figured out.

?

??? 1, the relative path of PHP is based on the script to run, for example, A contains b,b contains C, if a, C in the same level of directory, then B contains the path of C should be relative to a, if B, C in the same level of directory, then B contains the path of C is relative to C.

??? 2. Regardless of how the. php script is included, dirname (__file__) Gets the absolute path to the folder where the script is located.


??? These two rules are difficult to use accurately, at least I myself often get dizzy, so I used a more trickery way, I wrote a path.php, so very few mistakes.


???
????? Define (' Root_path ', DirName (__file__));
????? Define (' Action_path ', Root_path. /action/');
????? Define (' Bean_path ', Root_path. /bean/');
????? Define (' Dao_path ', Root_path. /dao/');
????? Define (' Ipadview_path ', Root_path. /ipadview/');
????? Define (' View_path ', Root_path. /view/');


??? ?>

?

?

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