Advertisement

05.28.2008 at 11:44AM PDT, ID: 23439147
[x]
Attachment Details

PHP require and relative path problem

Asked by krypto2000 in PHP Scripting Language

Tags: PHP, PHP, 5, PHP 5, Appache latest version

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)
Start Free Trial
[+][-]05.28.2008 at 02:12PM PDT, ID: 21664438

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Tags: PHP, PHP, 5, PHP 5, Appache latest version
Sign Up Now!
Solution Provided By: hernst42
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628