|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
||||
|
||||
|
PHP's include/require
I love this tag... I'm using it the same way most people are using it, for headers & footers...
how do you require something in a folder outside of the one that the script is in? ideally, i'd like a generic tag that will call a certain header in one folder... i realize its probably not very clear... so here's an example... lets say i have header.php in the folder /config/ (sub-folder from within the webspace root folder) i've tried require('/config/header.php'); but that doesn't seem to work... I realize require('config/header.php'); would work for that file in the same directory, but what about files in various directories? Alternatively, i can't help but notice this part in the error line: (include_path='.;c:\php4\pear') A supplement question could be, how do i modify the include_path? |
|
#2
|
||||
|
||||
|
i figured it out... =)
include_path was located in php.ini it was commented out, so i de-commented it... added the path i wanted (the absolute path to the webspace root path)... restarted apache, and it seemed to work... |
|
#3
|
||||
|
||||
|
you could do something like this..
say the root of your webdir is this /var/wwwdir/html and you have your config files in /var/wwwdir/config then you could do this for your include PHP Code:
|
|
#4
|
|||
|
|||
|
General purpose way to get root path
I got this code from somewhere else and it works like a charm to get the root path:
PHP Code:
|
|
#5
|
|||
|
|||
|
Doing the trick for me is using the global $_SERVER['DOCUMENT_ROOT'] variable.
Your include would become PHP Code:
This way you're not depending on the path setting in the php.ini file and is your script or application portable over various web-platforms, as long as they provide this global $_SERVER variable. Regards, |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > PHP's include/require |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|