Created
October 9, 2014 21:51
-
-
Save Vinai/0f9df543b4b7f93e1f1a to your computer and use it in GitHub Desktop.
PHP use statements don't have to refer to existing classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Random\Example; | |
spl_autoload_register(function($class) { | |
echo "Autoload triggered for class $class\n"; | |
}); | |
echo "Importing class with use upcoming...\n"; | |
use Some\Example\Nonexistant\Class\Which\Will\Not\Trigger\The\Autoloader; | |
echo "use namespace done, autoloader not triggered so far\n"; | |
echo "class_exists with autoloader upcoming...\n"; | |
class_exists('Nonexistant'); | |
echo "class_exisis with autoloader done\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment