Re: Re: best way to properly build an include path *regardless* from where I am calling the include?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Govinda wrote:
> 
> On Jul 5, 2009, at 6:15 PM, Shawn McKenzie wrote:
>>
>> AFAIK, include '/somedir/somefile.php'; looks for that specific file in
>> that specific path because you gave an absolute path.
> 
> Well, that is what I wanted.
> So I tried this:
> include '/MY_inc_php/GovBC_php_functions.inc';
> but that fails.
> So I try this:
> include '/home/metheuser/public_html/MY_inc_php/GovBC_php_functions.inc';
> and it works.

So, depending upon you include path, yes.  The preceding slash states
that its an absolute path.  Starts at the root / nad the a path after that.

> 
> But if I ever have to move to a server where the "home" part of that
> path is not "home", or the "public_html" part of that path is not
> "public_html" (I dunno..  I do not run servers), then my includes break.
> 
>>
>> If you do include 'somedir/somefile.php'; then it looks in all paths in
>> the include path
> 
> Here ^^^  when you say "it looks in all paths in the include path", what
> are you talking about?
> It seem like you do not mean the path in my include statement itself,
> but in some string (path) that is built and stored somewhere else.  (?)
> Where do I build/store that?
> 
>> and appends somedir/somefile.php.  So if your include
>> path contained /usr/share/php/PEAR for example and somefile.php was at
>> /usr/share/php/PEAR/somedir/ then it would find it.
> 
> 
> 
In include_path in php.ini or you can set it in your script.  It's the
path that PHP looks in when you include a file.

Sorry, I thought you knew this and were wanting to know whey one thing
worked and one didn't.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux