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
https://forums.phpfreaks.com/topic/251756-require/
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
https://forums.phpfreaks.com/topic/251756-require/#findComment-1291043
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.