How can I use PHP to grab files from different directories -


i understand in html, can use ../../../ include content included in other folders.

i have php code , i'm wondering how can use ../../../ before header.php?

<?php ob_start(); include("../../../header.php"); $buffer=ob_get_contents(); ob_end_clean(); $buffer=str_replace("%title%","homepage",$buffer); echo $buffer; ?> 

you can use chdir() php function , getcwd(). im suggest use constant source path location..

try this:

<?php ob_start(); chdir("../../../"); $cwd =  rtrim(str_replace("\\", "/", getcwd()), '/').'/'; include($cwd."header.php"); $buffer=ob_get_contents(); ob_end_clean(); $buffer=str_replace("%title%","homepage",$buffer); echo $buffer; ?> 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -