nested include in php

Posted by aeonsleo on Stack Overflow See other posts from Stack Overflow or by aeonsleo
Published on 2010-06-11T07:34:33Z Indexed on 2010/06/11 7:53 UTC
Read the original article Hit count: 334

Filed under:
|
|

The directory structure:

  • C:/wamp/www/application/model/data_access/data_object.php

  • C:/wamp/www/application/model/users/user.class.php

  • C:/wamp/www/application/controller/projects.php

  • C:/wamp/www/application/controller/links/links.php

I have 2 php files data_object.php and user.class.php Now user.class.php has an include statement for data_object.php wchih is relative to user.class.php.These two files are under different directory hierarchy. Now I have to include this user.class.php in various files (like projects.php, links.php-which themselves are under different hierarchy) whenever i want to create a User() object.

The problem is the relative path for file inclusion of data_object.php does work for say projects.php but if i open links.php the error message says it could not open file data_object.php in user.class.php. What i think is for relative inclusion of data_object.php it is considering the path of the file in which user.class.php is included. I am facing such problems in more than one scenarios

I have to keep my directory structure the way it is but have to find a way to work with nested includes. I used Document root of session it give root path as C:/wamp/www/ i appended the path for data_object.php include but this is not working. (note: the forward slash is present after www) I am currently running on wamp server's localhost but after completion i have to host the solution on a domain. Pls help

© Stack Overflow or respective owner

Related posts about php

Related posts about include