Re: Hidden include_path Fall Back?

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

 



The default of php.ini starts with '.' in the first place, I think, so
unless you go out of your way to change it, you'll get '.' from a
fresh install anyway.

I personally would not rely on the behaviour of the code unless you
can find Documentation on http://php.net that says it will work this
way.

It cannot be that hard to append/prepend '.:' yourself to the
include_path...

On Wed, August 8, 2007 4:05 am, imacat wrote:
> Dear all,
>
>     Hi.  I'm new to this list.  I searched the list archive and
> couldn't
> find an answer.  I'm sorry if someone has asked before.
>
>     I found that include_path seems to have a hidden fall back that's
> not documented anywhere.  It seems to always look for files in the
> calling files' own directory.  The below is a piece of terminal log of
> a
> simple test case I produced for this.  The include_path does not
> include
> /tmp/phpinc/inc, but PHP can still find /tmp/phpinc/inc/inc02.php from
> /tmp/phpinc/inc/inc01.php solely with the name inc02.php.
>
> imacat@atlas /tmp/phpinc % find -type f
> ./test.php
> ./inc/inc02.php
> ./inc/inc01.php
> imacat@atlas /tmp/phpinc % cat test.php
> <?php
> set_include_path(dirname(__FILE__));
> echo "include_path is \"" . get_include_path() . "\".\n";
> echo "This is " . __FILE__ . ".\n";
> include "inc/inc01.php";
> ?>
> imacat@atlas /tmp/phpinc % cat inc/inc01.php
> <?php
> echo "This is " . __FILE__ . ".\n";
> include "inc02.php";
> ?>
> imacat@atlas /tmp/phpinc % cat inc/inc02.php
> <?php echo "This is " . __FILE__ . ".\n"; ?>
> imacat@atlas /tmp/phpinc % php test.php
> include_path is "/tmp/phpinc".
> This is /tmp/phpinc/test.php.
> This is /tmp/phpinc/inc/inc01.php.
> This is /tmp/phpinc/inc/inc02.php.
> imacat@atlas /tmp/phpinc %
>
>     I traced into the PHP source.  At line 1348 in the subroutine
> _php_stream_fopen_with_path() in main/streams/plain_wrapper.c, there
> is
> a piece of code saying that:
>
> ...
> 	/* check in provided path */
> 	/* append the calling scripts' current working directory
> 	 * as a fall back case
> 	 */
> 	if (zend_is_executing(TSRMLS_C)) {
> ...
>
>     I cannot find the reason of this fall back anywhere on the net.  I
> have a lot of scripts that "accidently" works because of this, which I
> do not know whether I should fix it or not.  Can I rely on this
> undocumented behavior?  Or will this be fixed in the future, so I had
> better fix my scripts in advance?
>
>     Thank you for your time in advance.
>
> --
> imacat ^_*'
> imacat@xxxxxxxxxxxxxxxxxx
> PGP Key: http://www.imacat.idv.tw/me/pgpkey.asc
>
> Tavern IMACAT's http://www.imacat.idv.tw/
> Woman's Voice http://www.wov.idv.tw/
> TLUG List Manager http://www.linux.org.tw/mailman/listinfo/tlug
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
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