Search code examples
phpphp-include

See the location from /includes


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"


Solution

  • $_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()