#46395 [Opn]: Inconsistent behaviour of require_once
| From: | ebosman at gmail dot com | Date: | Mon, 24 Nov 2008 17:33:18 +0000 |
| Subject: | #46395 [Opn]: Inconsistent behaviour of require_once | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-131268@lists.php.net to get a copy of this message | ||
ID: 46395
User updated by: ebosman at gmail dot com
Reported By: ebosman at gmail dot com
Status: Open
Bug Type: Directory function related
Operating System: Linux
PHP Version: 5.2.6
New Comment:
And then I forgot that I put the original include_path back, apologies
/var/www/bug/top.php /var/www/bug
/var/www/bug/subdir/sub.inc /var/www/bug
(and htmlized:)
Warning: require_once(../top1.inc) [function.require-once]: failed to
open stream: No such file or directory in /var/www/bug/subdir/sub.inc on
line 1
Fatal error: require_once() [function.require]: Failed opening required
'../top1.inc' (include_path='/usr/share/php:/usr/share/pear') in
/var/www/bug/subdir/sub.inc on line 1
Previous Comments:
------------------------------------------------------------------------
[2008-11-24 17:30:28] ebosman at gmail dot com
correction, for top.php it should be (still no difference):
/var/www/bug/top.php /var/www/bug
/var/www/bug/subdir/sub.inc /var/www/bug
(and htmlized)
Warning: require_once(../top1.inc) [function.require-once]: failed to
open stream: No such file or directory in /var/www/bug/subdir/sub.inc on
line 1
Fatal error: require_once() [function.require]: Failed opening required
'../top1.inc' (include_path='.:/usr/share/php:/usr/share/pear') in
/var/www/bug/subdir/sub.inc on line 1
(line difference in the previous comment was because of copy-pasting)
------------------------------------------------------------------------
[2008-11-24 17:15:22] ebosman at gmail dot com
Same result:
subdir/sub.php:
/var/www/bug/subdir/sub.php /var/www/bug/subdir
/var/www/bug/subdir/sub.inc /var/www/bug/subdir
/var/www/bug/top1.inc /var/www/bug/subdir
/var/www/bug/top2.inc /var/www/bug/subdir
top.php:
Warning: require_once(../top1.inc) [function.require-once]: failed to
open stream: No such file or directory in /var/www/bug/subdir/sub.inc on
line 2
Fatal error: require_once() [function.require]: Failed opening required
'../top1.inc' (include_path='/usr/share/php:/usr/share/pear') in
/var/www/bug/subdir/sub.inc on line 2
------------------------------------------------------------------------
[2008-11-24 09:52:56] jani@php.net
Try removing the . from your include_path setting.
------------------------------------------------------------------------
[2008-10-26 19:32:50] ebosman at gmail dot com
I added 'echo __FILE__," ",getcwd(), "\n";' to each line:
mkdir -p bug/subdir
echo '<?php echo __FILE__," ",getcwd(), "\n"; require_once
"../top1.inc"; ?>' > bug/subdir/sub.inc
echo '<?php echo __FILE__," ",getcwd(), "\n"; require_once
"sub.inc";
?>' > bug/subdir/sub.php
echo '<?php echo __FILE__," ",getcwd(), "\n"; require_once
"subdir/sub.inc"; ?>' > bug/top.php
echo '<?php echo __FILE__," ",getcwd(), "\n"; require_once
"top2.inc";
?>' > bug/top1.inc
echo '<?php echo __FILE__," ",getcwd(), "\n"; ?>' >
bug/top2.inc
The output for subdir/sub.php:
/var/www/bug/subdir/sub.php /var/www/bug/subdir
/var/www/bug/subdir/sub.inc /var/www/bug/subdir
/var/www/bug/top1.inc /var/www/bug/subdir
/var/www/bug/top2.inc /var/www/bug/subdir
and for top.php:
/var/www/bug/top.php /var/www/bug
/var/www/bug/subdir/sub.inc /var/www/bug
(and htmlized:)
Warning: require_once(../top1.inc) [function.require-once]: failed to
open stream: No such file or directory in /var/www/bug/subdir/sub.inc on
line 1
Fatal error: require_once() [function.require]: Failed opening required
'../top1.inc' (include_path='.:/usr/share/php:/usr/share/pear') in
/var/www/bug/subdir/sub.inc on line 1
This would be consistent with the first include method
(relative to the original file.) But in that case including
top2.inc should fail, which it doesn't.
------------------------------------------------------------------------
[2008-10-26 18:57:32] jani@php.net
Put 'echo getcwd(), "\n";' to each file before the require line.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/46395
--
Edit this bug report at http://bugs.php.net/?id=46395&edit=1