include: host, file, service

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
php77
Forum Newbie
Posts: 11
Joined: Wed Mar 28, 2007 1:12 pm

include: host, file, service

Post by php77 »

hi
I have 3 casual [s]Qs[/s] questions with the file path in the include_once();

1. current file independent:
I need to reach to a file through such a path:
http://www.somesite.com/mysite/somefile.php
but the file, which use this include at it's top, is in another directory.
when I use things like include_once('../../../current_file.php')
it sure works! but I want to path independent of the current file's path!

2. the service:
also, I don't know what service to declare to use, as this:
include_once('http://www.somehost.com/mysite/theFile.php')
is forbiden for "http://" could not be used. so what service?

3. host independence:
Can I use a combination of server variables, to make path including even
more independence of the current site place? something like using $_SERVER['DOCUMENT_ROOT']?

thank you
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Have you tried anything yet?

Have a look at dirname() and pathinfo(), realpath(), etc. The manual is a great place to look for these answers as well.
Post Reply