Jump to content

relative to include?


Recommended Posts

you wont as the included file will be included into a.php

 

any file paths that is in b.php will be relative from a.php and not b.php. This how includes work.

 

What you might want to do is set up a constant and call it ROOT that has an absolute path to your websites root, example path:

/usr/mysite_com/public_html/

 

Then when you go to use include you do something like this:

include ROOT . 'path/to/script/from/root/folder';

That will make your include use absolute paths rather than relative.

 

Or another option is to add the extended folder to the include_path if you have access to the php.ini, or you can use .htaccess / ini_set to modify the php configuration.

Link to comment
https://forums.phpfreaks.com/topic/46545-relative-to-include/#findComment-226656
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.