note 26711 rejected from function.include by maxim

From: Date: Sun, 10 Nov 2002 03:45:32 +0000
Subject: note 26711 rejected from function.include by maxim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-39250@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!".

« previous php.notes (#39250) next »