autoloading and undefined class constants

From: Date: Mon, 06 Jul 2009 02:49:39 +0000
Subject: autoloading and undefined class constants
Groups: php.internals 
Request: Send a blank email to internals+get-44714@lists.php.net to get a copy of this message
Hi folks, Just looking for a quick clarification on how class constant look ups are performed internally under circumstances when an autoload function is also called. Consider the following example: <?php function autoloader($className) { throw new Exception("Fail"); } spl_autoload_register("autoloader"); ?> <?php // Exception $obj = new NonExistantClass; ?> <?php // Fatal error $const = NonExistantClass::NON_EXISTANT_CONSTANT; ?> I would have assumed that since the autoloader threw an exception while attempting to load the non existant class, that internally, there would be no attempt to access the non existant constant (since surely that comes after the exception was thrown???) and we would get the Exception, rather than a Fatal error. Intended or a design error? Ben Bidner +61.7.3161.2000 (office) | +61.7.3009.0651 (fax) | +61.4.3201.5362 (mobile) http://www.vuetec.com/

« previous php.internals (#44714) next »