Using/Giving absolute path

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Using/Giving absolute path

Post by itsmani1 »

Hi

I wanted to use absolute path in includes ... If if use

http://www.site.com/inc/myfile.php it gives me error.

What's the best way to use it?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Using/Giving absolute path

Post by requinix »

Use the absolute path to the file as it is on the file system. In general,

Code: Select all

require $_SERVER["DOCUMENT_ROOT"] . "/inc/myfile.php";
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Using/Giving absolute path

Post by papa »

Maybe this can help: http://php.net/manual/en/reserved.variables.server.php

Edit: tasairis was faster.. :)
Post Reply