Here's a really simple solution to a common problem. Let's
say you want to include files the way that apache does,
relative to the document root (the root dir of your app).
Independent of what server you are on, so that you don't
have to specify an absolute path on your filesystem. At the
top of your page put:
<?php set_include_path( get_include_path() .
PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); ?>
Now anywhere you do an include you can do something like:
<?php include ( "Templates/header.inc") ?>
So, if your server files are in /var/www/mysite, this will
include /var/www/mysite/Templates/header.inc when it's on
your server. And if on your dev machine it's in
/user/myname/mysite, it will include
/user/myname/mysite/Templates/header.inc when it's on your
dev machine.
----
Server IP: 64.71.164.2
Probable Submitter: 74.12.187.202
----
Manual Page -- htt
p://www.php.net/manual/en/function.include.php
Edit -- https://master
.php.net/note/edit/78344
Del: integrated -- h
ttps://master.php.net/note/delete/78344/integrated
Del: useless -- http
s://master.php.net/note/delete/78344/useless
Del: bad code -- htt
ps://master.php.net/note/delete/78344/bad+code
Del: spam -- https:/
/master.php.net/note/delete/78344/spam
Del: non-english --
https://master.php.net/note/delete/78344/non-english
Del: in docs -- http
s://master.php.net/note/delete/78344/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78344
Reject -- https://mast
er.php.net/note/reject/78344
Search -- https://
master.php.net/manage/user-notes.php
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|