Page 1 of 1
create a default path
Posted: Tue Mar 22, 2005 5:20 pm
by bladecatcher
G'day All,
Sorry if this is the wrong place.
I somehow want to have a set path to a directory. So in my php code I can refer to say "include($mydir_path . "header.php")" in any script from any directory.
Can I set a permanent global variable $mydir_path = /var/www/mysite/mydir or is there a better way?
Thanking you in anticipation,
bladecatcher
btw, perhaps it can be set in apache??? that would be good? or php.ini etc???
Posted: Tue Mar 22, 2005 5:22 pm
by Pyrite
Yea, in php.in , add your main path to your include_path then you can just include the script by the filename itself
include_path
Posted: Tue Mar 22, 2005 5:57 pm
by bladecatcher
G'day Pyrite,
Thank you for your reply.
I've done a bit of a search which turned up "
http://au.php.net/manual/en/function.se ... e-path.php" (the User Contributed Notes are interesting) but let me get this right.
If I rename the relevant scripts I want to "include" to .inc and put them in the "inc" directory then edit php.ini to:
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
include_path "/var/www/inc"
php will then prepend that path to *all* .inc files?
tia
bladecatcher
Posted: Tue Mar 22, 2005 7:00 pm
by feyd
no, php will look through the path(s) supplied in the ini during the search for the file.
Posted: Tue Mar 22, 2005 8:20 pm
by bladecatcher
Thanks feyd.
My thought train was hijacked by an poor article that suggested to me that include_path was just for .inc files.
So if php can't find the file (any file) in the current dir, it searches through the include_path.
Can I somehow use that directive in apache's httpd.conf file? perhaps in a <VirtualHost *>
listing?
thanking you in advance,
bladecatcher
Posted: Tue Mar 22, 2005 8:27 pm
by feyd
yes, read up on how to change php configuration in httpd.conf ::
http://php.net/configuration.changes
Posted: Tue Mar 22, 2005 8:32 pm
by bladecatcher
Thanks feyd,
Think i'm away with it now. You've been a great help. Sorry if I'm a bit slow on the uptake occasionally
cheers,
bladecatcher
include_path recursive
Posted: Fri Mar 25, 2005 4:39 pm
by bladecatcher
G'day All,
Is there a way of making the include_path recursive. (i.e look in sub-directories)?
Thanking you in anticipation,
bladecatcher
Posted: Fri Mar 25, 2005 4:51 pm
by feyd
not without passing the child directory information to the include_path.. but why? you can use relative path data with it.
Posted: Fri Mar 25, 2005 5:14 pm
by bladecatcher
G'day feyd,
Thank you, you've been particularly helpful (and patient) to me. Your taking the time to pass on your considerable knowledge is greatly appreciated.
Both relative and absolute paths have their own draw backs depending on the situation.
I'm currently stewing over how best to construct my site as your probably aware. Decisions I make now could save or create a lot of pain further down the track.
For a number of reasons I'm splitting the site up using named subdomains, those links (between) will be absolute others absolute to the server (/var/www/xyz/page.html) others relative.
I'm thinking about having a link building include so that links do not require updating (a labourious task).
Has there been discussion on this? If so could you give me a hint on a search criteria please?
and ... I think you've answered my question.
and ... do you have any comment on my earlier .inc file question?
Thanking you once again,
bladecatcher
Posted: Fri Mar 25, 2005 5:20 pm
by feyd
which are you talking about? Thus far, you have had 4 posts involving .inc.
Posted: Fri Mar 25, 2005 5:27 pm
by bladecatcher
G'day feyd,
<quot>which are you talking about? Thus far, you have had 4 posts involving .inc.</quote>
"What ia an .inc file?"
There was a few replies, none decisive. And my googling didn't work (i'm not good at it).
also
Has a link builder been discussed?
tia
blade
Posted: Fri Mar 25, 2005 6:19 pm
by Joe
"What ia an .inc file?"
An include file containing variables, definitions etc.