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 such a directory structure/classes/. class. php/classes/B. class. php/c. phpa. class PHP multi-layer require problem, please php expert advice!
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 ");
?>
/C. php
$ Basedir = dirname (_ FILE __);
Require_once ($ basedir. "classes/a. class. php ");
?>
------ Solution --------------------
You can use an absolute path.
No problem with the introduction.
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