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
Share on other sites

i agree with wildteen's suggestion for using ini_set(). you can do that from within your PHP scripts and it makes life a whole lot easier because maintenance is easy and porting your code isn't an issue.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.