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
Post a Comment