Voting

: five plus two?
(Example: nine)

The Note You're Voting On

harvey dot NO_SPAM dot robin at gmail dot com
18 years ago
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"
* }
*/
?>

<< Back to user notes page

To Top