PHP multi-layer require

Source: Internet
Author: User
PHP multi-layer require problem, please php expert advice! I am doing. net, not too familiar with php. recently I want to build a private website and use php. I encountered a problem. suppose my website has a directory structure like classesa. class. phpclassesb. class. phpc. phpa. class. php, B. class. php is a Class c. php is a multi-layer PHP require problem on the page. please be advised by a php expert!
I am a. net Developer and I am not very familiar with php. recently I want to build a private website and use php. I encountered some problems.

Assume that my website has such a directory structure.

/Classes/a. class. php
/Classes/B. class. php
/C. php
A. class. php, B. class. php are two classes, and c. php is a page.

If. class. reference in php (require_once) B. class. php, c. php references. class. php, run c. php reports an error. B cannot be found. class. php

How can we solve such a multi-layer reference problem?

------ Solution --------------------
C. How does php require?
------ Solution --------------------
Is there no correct path?
------ Solution --------------------
/Classes/a. class. php
$ Basedir = dirname (_ FILE __);
Require_once ($ basedir. "B. class. php ");
?>

/Classes/B. class. php
$ Basedir = dirname (_ FILE __);
?>

/C. php
$ Basedir = dirname (_ FILE __);
Require_once ($ basedir. "classes/a. class. php ");
?>
------ Solution --------------------
You can use an absolute path.
No problem with the introduction.

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.