Ninjakreborn Posted October 23, 2006 Share Posted October 23, 2006 I never had this problemWith includes. I have my config.php and a few include's on itThe thing I don't get, when it's connected to the root directory pages it works, but now I am starting to get inclusion errors when adding it to processor's in the processor folderI have my general include like this for the root folder's[code]<?phprequire_once './master/config/config.php';?>[/code]Now on my config page I have one's like[code]// Handling php security issuesinclude './master/config/functions/security.inc.php'; // include file with security functionserror(5); // function to set error level, defaulted to all and strict.inisettings("safe");// include master function controllerinclude './master/config/functions/master.inc.php';[/code]The current problem though, this all work's properly with the other. It come's down to the fact that there are a few problem's with something like a page within the master folder like/master/includes/meta.inc.phpin this one, Ihave the include's but it's not workingin that folder, it give's me inclusion errorsis there a way I can setup those include's to make them work I just want to be able to use 1 require statement for all pages at the top, and it automatically include all the other pages without me having to modify all my include's for each page specifically, that wouldn't be possible anyway? Quote Link to comment https://forums.phpfreaks.com/topic/24867-includes/ Share on other sites More sharing options...
redbullmarky Posted October 23, 2006 Share Posted October 23, 2006 when it comes to using 'common' files, i always tend to find $_SERVER['DOCUMENT_ROOT'] works quite well, as it then doesnt matter whether the common file is included from a file in the root, a sub dir, a sub sub dir, etc.common.php:[code]<?php$docroot = $_SERVER['DOCUMENT_ROOT'];include($docroot . '/master/config/config.php');include($docroot . '/master/somethingelse.php');include($docroot . '/helloworld.php');?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24867-includes/#findComment-113336 Share on other sites More sharing options...
Ninjakreborn Posted October 23, 2006 Author Share Posted October 23, 2006 Thank's that's just what I needed. Quote Link to comment https://forums.phpfreaks.com/topic/24867-includes/#findComment-113337 Share on other sites More sharing options...
Ninjakreborn Posted October 23, 2006 Author Share Posted October 23, 2006 That solved a shitload of problems.Now what about using this for css and image names.like I tried<link rel="stylesheet" type="text/css" href="<?php echo $docroot; ?>/css/global.css" />I tried that and it didn't work, it wasn't reading the style's why.That's not what I was originally using it for, but it was idea, unless you don't think it's worth the time?I was going to try the same thing for javascript, and css.IS that going to work, or are there going to be different affect's with those. Quote Link to comment https://forums.phpfreaks.com/topic/24867-includes/#findComment-113343 Share on other sites More sharing options...
redbullmarky Posted October 23, 2006 Share Posted October 23, 2006 this one's even easier. in HTML, EVERYTHING is relative to the docroot - so just use a trailing slash to reference the root of your website. works for anything HTML - css, javascript, etc.[code]<link rel="stylesheet" type="text/css" href="/css/global.css" />[/code]hope that helpscheersMark Quote Link to comment https://forums.phpfreaks.com/topic/24867-includes/#findComment-113357 Share on other sites More sharing options...
Ninjakreborn Posted October 23, 2006 Author Share Posted October 23, 2006 hmm ok.This should help me make things more re-usable, and less work.Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/24867-includes/#findComment-113369 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.