Jump to content

require()


richiejones24

Recommended Posts

Is there a better way to define the page name other than 

 require("./anyfolder/any.php"); 

trouble is i define the page by using ./myfole/anyfile.php but if  the page is called from deeper inside my site it dose not work. i have to change all the includes and put an additional . so it ends up looking like this ../myfole/anyfile.php

 

Link to comment
Share on other sites

$_SERVER['DOCUMENT_ROOT'] will give you the absolute file system path to your document root folder (kind of why they named it what they did.) You can then append (concatenate) your path/filename.ext on to that to produce an absolute file system path that will work regardless of which file actually includes your file.

 

If that doesn't accomplish what you want, you can use the include_path setting to get php to search for your include files in specific folders.

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.