note 57545 added to function.require-once
| From: | georg_gruber at yahoo dot com | Date: | Thu, 06 Oct 2005 22:06:42 +0000 |
| Subject: | note 57545 added to function.require-once | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96535@lists.php.net to get a copy of this message | ||
A very interesting behaviour of require_once (and probably all include commands):
consider the following files:
/index.php -> require_once('/inc/library.php');
/function1.php -> print('/function1.php');
/inc/library.php -> require_once('function1.php');
/inc/function1.php -> print('/inc/function1.php');
Note that /function1.php and /inc/function1.php are files with the SAME filename in different
folders.
If you "/index.php" is executed it will output
"/function1.php".
Although /index.php "includes" /inc/library.php the scope of the file is still /index.php
therefor /function1.php will be found even it could be asumed the /inc/function1.php is the correct
one.
And it gets more interesting: if you delete /function1.php and execute /index.php PHP checks this
and "includes" /inc/function1.php.
----
Manual Page -- http://www.php.net/manual/en/function.require-once.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57545
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57545&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57545&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57545&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57545&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57545&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57545&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57545&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57545&report=yes
Search -- http://master.php.net/manage/user-notes.php