Reputation:
in my root folder of my domain i have files header.php and footer.php, i have created a new folder and file in the new folder and wanted to include the header and footer files from main. So the paths are: main folder: example.com/header.php new file: example.com/folder/new_file.php <- in this file i want to include the header.
I have tried:
<?php include "header.php"; ?>
<?php include "/header.php"; ?>
<?php include "./header.php"; ?>
<?php include "../header.php"; ?>
and none of them work. Any help would be appreciated thanks.
Upvotes: 0
Views: 131
Reputation:
Thanks for all of your support. To answer my question thanks to all here are the answers.
<?php include( $_SERVER['DOCUMENT_ROOT'] . '/header.php' ); ?>
and php include "../header.php";
DO work and i was able to include a file from main directory so thanks to david and code360.
second part of why the css file was not being read is because i had it like this in header.php file:
<link rel="stylesheet" href="css/bootstrap.css">
and missed the first "/"
Thanks again to code360
Upvotes: 0
Reputation: 2783
<?php include( $_SERVER['DOCUMENT_ROOT'] . '/header.php' ); ?>
it's will work .try may be its help in any of your files
Upvotes: 1