Andy17 Posted August 27, 2010 Share Posted August 27, 2010 Hello, I have a small and annoying problem. Imagine that I have a main folder on my FTP server which has index.php and I then have a php folder for all of my small scripts and an includes folder for misc files. So, for instance http://www.somedomain.com/index.php http://www.somedomain.com/php/somescript.php http://www.somedomain.com/includes/somefile.html Inside somescript.php, I need to use one of the files from the includes folder, like this for example: require('../includes/somefile.html'); This is all fine, but the problem is when I include the PHP file on my index.php page. Then I am telling PHP to go one step back to find the includes folder, but the problem is that it only needs to go one step back if it PHP script is not included on some page outside of the php folder. If I run php/somescript.php, there is no problem, but if I include php/somescript.php on my index.php, then there is trouble! I hope you guys understand what I mean. Thanks in advance! PS - I would appreciate if the solution is not about moving php/somescript.php or using full URLs in my includes. Quote Link to comment https://forums.phpfreaks.com/topic/211871-includerequire-problem/ Share on other sites More sharing options...
Adam Posted August 27, 2010 Share Posted August 27, 2010 Set the include path to the document root (and to the current include path), so when you include a file you always specify it from the document root like: require 'includes/somefile.html'; .. No matter where you are. Quote Link to comment https://forums.phpfreaks.com/topic/211871-includerequire-problem/#findComment-1104335 Share on other sites More sharing options...
Andy17 Posted August 27, 2010 Author Share Posted August 27, 2010 I was having a few problems with it, but it seems as if I resolved it. Thanks a lot for the link - that's pretty cool! Quote Link to comment https://forums.phpfreaks.com/topic/211871-includerequire-problem/#findComment-1104346 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.