include file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

DigitalRice
New php-forum User
New php-forum User
Posts: 29
Joined: Fri Jun 27, 2003 10:05 pm

include file

Postby DigitalRice » Thu Sep 11, 2003 7:01 pm

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

toweter
New php-forum User
New php-forum User
Posts: 26
Joined: Sat Aug 30, 2003 9:04 am

Postby toweter » Fri Sep 12, 2003 3:27 am

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

sigix
php-forum Active User
php-forum Active User
Posts: 364
Joined: Mon Jul 14, 2003 9:39 pm
Location: /Earth/Xion

Postby sigix » Fri Sep 12, 2003 3:40 am

or you can user the DOCUMENT_ROOT

$_SERVER['DOCUMENT_ROOT']

and then add the appropriate path ..... :arrow:

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

include

Postby ruturajv » Sat Sep 13, 2003 12:17 am

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: Select all

include('/file.php');


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest