note 57545 deleted from function.require-once by cmb
| From: | cmb@php.net | Date: | Wed, 02 Sep 2015 15:22:02 +0000 |
| Subject: | note 57545 deleted from function.require-once by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-203571@lists.php.net to get a copy of this message | ||
Note Submitter: georg_gruber at yahoo dot com
----
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.