PHP require / include only works once per script and then fails

This is not a problem per se, but it is undermining me and I would appreciate any help. It may be quite obvious, but I don't see it.

$root_path = $_SERVER['DOCUMENT_ROOT'] 
require($root_path .'template/header.php')
require($root_path .'template/footer.php')

      

The script will include one or the other, but not both. It will run and include the header but not the footer, if I swap them around it will load the footer first but not the header.

I tried using include

instead require

, but get the same result.

It gives an error allow_url_include = 0

. I know this will help solve this problem, but my question is, why is this happening? Why would it include one file but not the other? Is there a way to make them work without including it allow_url_include

(I'm trying to get my head around security). I have PHP 5.3 and I am running WAMP. Thanks in advance for your help!

+2


a source to share


3 answers


Maybe $root_path

changed in header.php or footer.php?



0


a source


It looks like you are overriding $root_path

in the included file.



0


a source


There is nothing wrong with what you have written. As others have said, something is happening with $root_path

, or the script ends before it gets to that.

Make it var_dump($root_path)

right above the footer. If that works, you know it's about enabling. If it still doesn't work, do some echoes inside your footer to see if it gets into the file.

0


a source







All Articles