troubleshooting Question

PHP require and relative path problem

Avatar of krypto2000
krypto2000 asked on
PHP
2 Comments1 Solution1409 ViewsLast Modified:
Hi  !

I developped a library in PHP5 and  putted it into a directory of my website ("classes").
I created then three subfolders : "business", "data", "interface"
so my layer are well separeted. But of course, some files from the "business" directory must reference some files from the "data" directory.

Everything works fine as long as I include thoses classes from php document which are located into my root directory.

Example :
index.php -> require_once 'classes/business/user.class.php' ==> OK

but then :
order/order_details.php -> require_once '../classes/business/user.php' ==> FAIL

But where the error occurs is not in the order_details.php file but in the user.class.php which can't find other required files that are not in the same directory as user.class.php (ex : classes/data/database.class.php which is referenced as ../data/databse.class.php)

Is there a way to make that works ? I don't want to put all my interface files in the root directory and i want to be able to use my classes from anywhere in my website !

Please help it is urgent !!!

(I hop it is clear :-/ Feel free to ask me more details)
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros