Forum Moderators: coopster
<?php include "includes/header.php";?>
That works just fine when it comes to files in the main directory. But that was overcrowded, and I wanted to create sub-directories for expanding the site. However, attempting to do these following techniques failed to provide the desired result with files in the sub-directories:
<?php include "/includes/header2.php";?>
<?php include "../includes/header2.php";?>
<?php include "http://www.****.com/includes/header2.php";?>
Anyone have any ideas on what I should do? Thanks for any help you could provide...
Lou
for a tags / == website root
for includes / == server root
PHP Predefined Variables - $_SERVER [ca.php.net]
so we need to have includes with an absolute path. This way you can move them anywhere within the site and they won't break
to reference the site root we can use
$_SERVER['DOCUMENT_ROOT']
so
<?php include $_SERVER['DOCUMENT_ROOT'] . "/includes/header2.php";?>
there are a ton of other useful variables in the $_SERVER array as well