note 73146 added to function.spl-autoload-register

From: Date: Sat, 10 Feb 2007 13:54:22 +0000
Subject: note 73146 added to function.spl-autoload-register
Groups: php.notes 
Request: Send a blank email to php-notes+get-123219@lists.php.net to get a copy of this message
This function is smart enough not to add the same loader twice. This seems to work for all of the different loader formats. Example: <?php class ALoader { static function load($class) { return true; } } function anotherLoader($class) { return true; } $F = new ALoader; spl_autoload_register(array('ALoader', 'load')); spl_autoload_register(array('ALoader', 'load')); spl_autoload_register(array($F, 'load')); spl_autoload_register('anotherLoader'); spl_autoload_register('anotherLoader'); var_dump(spl_autoload_functions()); /* * Results on PHP5.2 CLI, linux. * array(2) { * [0]=> * array(2) { * [0]=> * string(7) "ALoader" * [1]=> * string(4) "load" * } * [1]=> * string(13) "anotherLoader" * } */ ?> ---- Server IP: 64.71.164.2 Probable Submitter: 80.229.22.156 ---- Manual Page -- http://www.php.net/manual/en/function.spl-autoload-register.php Edit -- https://master.php.net/note/edit/73146 Del: integrated -- https://master.php.net/note/delete/73146/integrated Del: useless -- https://master.php.net/note/delete/73146/useless Del: bad code -- https://master.php.net/note/delete/73146/bad+code Del: spam -- https://master.php.net/note/delete/73146/spam Del: non-english -- https://master.php.net/note/delete/73146/non-english Del: in docs -- https://master.php.net/note/delete/73146/in+docs Del: other reasons-- https://master.php.net/note/delete/73146 Reject -- https://master.php.net/note/reject/73146 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123219) next »