Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

include's organisation

Status
Not open for further replies.

litton1

Technical User
Apr 21, 2005
584
GB
Hello all, I am wondering is there a way that I can organise my include files, at the moment they reside in /src/ but I would like to be able to organise them into folders as the include folder has about 20 files at the moment but there will no doubt be more as time goes on. I tried to put one in /src/ and call by include “/news/newsinclude.php” but I get the usual error that states that there is no file there. Has anybody else had any success with this type of organisation approach. Thanks in advance

Binary Intelligence, true or false?
 
You must keep in mind that include(), require() and the other PHP functions which access the filesystem operate on the entire filesystem. So when you tell PHP to get a file from "/news", PHP expects that directory to be at the top of your filesystem, not relative to any given spot.

Take a look at the runtime configuration setting "include_path". If you use a relative path in an include statement ("news/newsinclude.php" rather than "/news/newsinclude.php") then PHP will look for the file relative to the current directory of the running script as well as all directories in include_path.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Excellent! thanks, not sure why I didn’t try that. Thanks again

Binary Intelligence, true or false?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top