note 26711 added to function.include
| From: | mgv at fx dot ro | Date: | Sun, 10 Nov 2002 02:58:22 +0000 |
| Subject: | note 26711 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-39248@lists.php.net to get a copy of this message | ||
I'm trying to design an elegant include dependency structure for a large project. My idea was
using return() in libraries if some dependency wasn't loaded, and have an include manager parse
the result and first include the dependency and then *retry* loading the original file after
including the dependencies. To my unpleasant surprise, class definitions below the return()
statement were loaded by PHP even if the return() did execute above it! The code below the return
statement didn't run though, but since the class definition was loaded, retrying to load the
same file resulted in a PHP error saying that I'm trying to duplicate a class!
For instance:
--- myFile.php ---
<?
include("myLib.php");
if (class_exists("myclass")) {
echo("It's defined!");
}
?>
--- myLib.php ---
<?
return(1);
echo("Whoaa! return() didn't do a thing!");
class myClass
{
function myClass() {}
}
?>
Executing myFile.php *will* echo "It's defined!" but won't echo "Whoaa!
return() didn't do a thing!".
--
http://www.php.net/manual/en/function.include.php
http://master.php.net/manage/user-notes.php?action=edit+26711
http://master.php.net/manage/user-notes.php?action=delete+26711
http://master.php.net/manage/user-notes.php?action=reject+26711