Jump to content

Include/require problem


Andy17

Recommended Posts

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. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.