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.