0

I have a number of classes (Managers and Data) that have include_once's. Seems that when I include a data class into a manager, they work fine together...but when I include the manager class in my view to get the data, it's broken. I assume due to the view actually adding the manage to itself which makes the path to the data incorrect since the view is up 3 directories from root /adoptions/apps/add/ and the manager and data classes are 4 directories from the root. Is that correct?

Since I am new to PHP I noticed that / takes me further back than just the web root. I am running apache on a windows machine and the path to the htdoc is actually

c:/Program Files(x86)/Zend/Apache2/htdocs/mywebsite 

(if that helps at all). I would like to just have all my includes be something like

 include_once('/com/mywebsite/data/people/People.class.php';

Thanks!

1
  • I suggest you share some error messages so your question becomes more clear. Please do a error_reporting(~0); ini_set('display_errors', 1); at the very beginning of your script. Additionally you should enable error logging and follow the error log. Commented Aug 30, 2012 at 7:45

1 Answer 1

2

You need to set the include_path property in the php.ini file of your installation. Clear the existing entries if you wish, or add a semi-colon and then c:/Program Files(x86)/Zend/Apache2/htdocs

Then all paths will be relative to that, so you can just go include("/mywebsite/data/people/People.class.php");

Alternatively you can do this in .htaccess file:

php_value include_path ".;c:/Program Files(x86)/Zend/Apache2/htdocs"

or one of these two methods in your php itself:

ini_set("include_path",".;c:/Program Files(x86)/Zend/Apache2/htdocs");

Or set_include_path(".;c:/Program Files(x86)/Zend/Apache2/htdocs");

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.