I have upload my site to my server, but he can't find the folder /includes/header.php
. Can I echo the location where he looks to the file. The only error I see now is:Warning: include(/includes/header.php) [function.include]: failed to open stream
.
But what is the "start" location? Can I echo this?
EDIT :
The thing I want to know is where the location is when you use include("/blabblabla").
So the "home path"
$_SERVER['DOCUMENT_ROOT']
The document root directory under which the current script is executing, as defined in the server's configuration file.
include $_SERVER['DOCUMENT_ROOT'].'/includes/header.php';
__DIR__
The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(FILE). This directory name does not have a trailing slash unless it is the root directory.
include (__DIR__"/includes/header.php");
Font: DIR
getcwd() Gets the current working directory
include getcwd()."/includes/header.php";
Font: getcwd()
The php include path will take a file system path as a string parameter. The path can be either absolute e.g.
include('/home/yourusername/public_html/includes/somethingtoinclude.php');
or relative to the location of your script. So if your script is in /home/yourusername/public_html/ and your includefile is in /home/yourusername/public_html/includes/ the following will work
include('includes/somethingtoinclude.php');
Note that include will also search in all directories in the php include path as set in php.ini in the include_path directive