Jump to content

Recommended Posts

I never had this problem
With includes.  I have my config.php and a few include's on it
The 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 folder
I have my general include like this for the root folder's
[code]<?php
require_once './master/config/config.php';
?>[/code]
Now on my config page I have one's like
[code]// Handling php security issues
include './master/config/functions/security.inc.php'; // include file with security functions
error(5); // function to set error level, defaulted to all and strict.
inisettings("safe");
// include master function controller
include './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.php
in this one, Ihave the include's but it's not working
in that folder, it give's me inclusion errors
is 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?
Link to comment
https://forums.phpfreaks.com/topic/24867-includes/
Share on other sites

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]
Link to comment
https://forums.phpfreaks.com/topic/24867-includes/#findComment-113336
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/24867-includes/#findComment-113343
Share on other sites

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 helps
cheers
Mark
Link to comment
https://forums.phpfreaks.com/topic/24867-includes/#findComment-113357
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.