Let’s say I have three php pages namely Header.php, Footer.php and LeftSideBar.php in the following directory
C:\wamp\www\zoomin\header_footer_sidebar
and usual php pages in the following directory.
C:\wamp\www\zoomin\www.zoomin.com
I can include those three pages as follows.
<?php
require_once("../header_footer_sidebar/Header.php");
require_once("../header_footer_sidebar/LeftSideBar.php");
require_once("../header_footer_sidebar/Footer.php");
?>
This can work fine but when I need to keep pages in other directories like the following,
C:\wamp\www\zoomin\www.zoomin.com\directoryA\directoryB\directoryC
I need to copy those three pages into an appropriate directory because Header.php, Footer.php and LeftSideBar.php may contain some urls at least some image urls of some other directory which would not work with the preceding url.
I want to keep Header.php, Footer.php and LeftSideBar.php only in the following directory as mentioned above.
C:\wamp\www\zoomin\header_footer_sidebar
regardless of in which directory I save my web pages. The following approach would not work in this case.
$protocol."://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
or
$protocol."://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
Is there a way to suit this requirement?
Check your
include_pathin php.ini.