note 113901 deleted from language.oop5.autoload by crell

From: Date: Mon, 04 Apr 2022 16:09:40 +0000
Subject: note 113901 deleted from language.oop5.autoload by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218027@lists.php.net to get a copy of this message
Note Submitter: julian at jxmallett dot com ---- The tip to use spl_autoload_register() instead of __autoload() should be taken seriously. It seems that __autoload() doesn't always get called when calling an unloaded class within a class, eg: <?php class MyClass { public static function doStuff() { //do some stuff $a = MyOtherClass::otherStuff(); } } ?> Code similar to that gave me a 'class not found' error when using __autoload(). Using spl_autoload_register() with the exact same autoload function fixed the problem.

« previous php.notes (#218027) next »