PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
How can I set a classpath or something similar to mark the location of all classes. If I am in /php/database/DbHosts.php and I want to get an instance from /php/Hosts.php I have now idea how I can handle this. (something like $hosts = new ../Hosts )
If you use include_once() it solves problems where class files are included multiple times because they're included in one file and also included in a file that that page includes...
Thank you for your help, but I get the following errors:
Warning: Unable to access ../database/DbHost.php in /usr/local/httpd/htdocs/cat/php/rendering/searchHostResult.php on line 3
Warning: Failed opening '../database/DbHost.php' for inclusion (include_path='') in /usr/local/httpd/htdocs/cat/php/rendering/searchHostResult.php on line 3
Fatal error: Cannot instantiate non-existent class: dbhost in /usr/local/httpd/htdocs/cat/php/rendering/searchHostResult.php on line 5
If I switch the safe mode off The first Warning disappears. I gues the following: The safe mode has prevented searchHostResult.php from accessing another directory. After turning the safe mode off it was possible to access ../database/DbHost.php but it was not possible to open this file.
The webserver has r-x - rights for accessing the files.
Is there any other option I have to set for accessing this php-files?
Have you taken a look at the manual and read the section regarding "include_path"s? Also check what your $DOCUMENT_ROOT or $_SERVER[DOCUMENT_ROOT] var is set to.
the warnings are caused by a stupid failure of me. searchHostsResult is included by index.php, which is stored in another folder. My include was in relation from searchHostResult to host.php but after changing it to the relation from index.php to hosts.php it worked fine.