File 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
michaeru
Forum Commoner
Posts: 28
Joined: Sun Mar 07, 2010 5:22 pm

File Path

Post by michaeru »

Is it better to use the full path when including or requiring a file? Or is it just okay to use something like this include('../../file.php')?

And is it safe to include something like this include('www.website.com/fileToInclude/file.php')?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: File Path

Post by requinix »

Using relative paths is a bad idea. Including from a website is a horrible idea.

Code: Select all

include $_SERVER["DOCUMENT_ROOT"] . "/path/to/file.php";
michaeru
Forum Commoner
Posts: 28
Joined: Sun Mar 07, 2010 5:22 pm

Re: File Path

Post by michaeru »

Okay, thanks.
Post Reply