Questions about the Include path

Source: Internet
Author: User
About include path issues

, the wording of my action.php quote: include ' class/users.php ';
The wording of my uploadpic.php quote: ". /class/users.php ";
My users.php refers to the connection database: include '. /admin/class/connect.php ';
The problem is users.php reference connection database, if so, action.php will prompt the connection database failed, but uploadpic.php normal!
If written as include ' admin/class/connect.php ', that action.php normal, but uploadpic.php will prompt to connect to the database failed!
Is the problem of the path, uploadpic.php to return to the upper level to refer to, action.php do not need.
Find a solution!!!
------Solution--------------------


In your program's root file definition
Define ("Root_dir", DirName (__file__));
For example, your action.php joins the definition above
Include Root_dir. '/class/users.php ';

Include Root_dir. '/admin/class/connect.php ';


------Solution--------------------
The principles of include are:
Always a top-down quote
References in all referenced files are relative paths to relative portal files
  • 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.