spl_autoload_004.phpt 643 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. SPL: spl_autoload() with static methods
  3. --INI--
  4. include_path=.
  5. --FILE--
  6. <?php
  7. class MyAutoLoader {
  8. static function autoLoad($className) {
  9. echo __METHOD__ . "($className)\n";
  10. }
  11. }
  12. spl_autoload_register(array('MyAutoLoader', 'autoLoad'));
  13. // and
  14. $myAutoLoader = new MyAutoLoader();
  15. spl_autoload_register(array($myAutoLoader, 'autoLoad'));
  16. var_dump(spl_autoload_functions());
  17. // check
  18. var_dump(class_exists("TestClass", true));
  19. ?>
  20. --EXPECT--
  21. array(1) {
  22. [0]=>
  23. array(2) {
  24. [0]=>
  25. string(12) "MyAutoLoader"
  26. [1]=>
  27. string(8) "autoLoad"
  28. }
  29. }
  30. MyAutoLoader::autoLoad(TestClass)
  31. bool(false)