How can I introduce the same php file to php in different folders?

Source: Internet
Author: User
How can I introduce the same php file to php in different folders? As the website requires, I want to go to www/sub. www/includes/application_top.php is introduced in php, but this will cause a path error. I am using zencart. how can I solve this problem?


Reply to discussion (solution)

Introduce www/shortdes/application_top.php in www/sub. php

Require '../schemdes/application_top.php ';

We recommend that you paste the error information for analysis.

I mean, without changing or modifying the code in application_top.php as little as possible, it will not cause any path errors if php references this file in depth, such as www/sub. php reference .. /includes/application_top.php will report an error.. php and B. php

An error has been written in application_top.php. it should be:
Require ('A. php ');
Require ('B. php ');

Your project has access to the upper-level directory from the lower-level directory, which shows that your Directory design is unreasonable.
The reasonable design is always the upper-layer access lower-layer

If you cannot avoid it, you can
1. set the constant ROOT_PATH in the public (usually comfig. php) for file introduction.
2. execute
Ini_set ('include _ path', ini_get ('include _ path'). PATH_SEPARATOR. '/www /'));
Dynamically set search path
3. if possible, set include_path directly in php. ini.

Thank you, two cool people.

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.