include file

A

Anonymous

Guest
hi expert
i have trouble of include file that if the directory is too deep, it cannot include it, how come?

here is my problem.

http://localhost/x/y/z.php
from z.php i want to include a file from main directory, which is from http://localhost/

but it keeps giving me error. can i fix it?

thanks
 
you can inlude the file like that:
include("../../../index.php");
or:
include("C:/example/myphp/index.php");
 
or you can user the DOCUMENT_ROOT

$_SERVER['DOCUMENT_ROOT']

and then add the appropriate path ..... :arrow:
 
if you are on the same server [localhost] then you can give the relative path of the include file depending the location of the file eg. if the file is in the DocumentRoot directory of the VirtualHost then give
Code:
include('/file.php');
 
Back
Top