Created
September 19, 2012 10:29
-
-
Save Stelian/3748899 to your computer and use it in GitHub Desktop.
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
/** Instantiating a class **/ | |
function __autoload($name) { | |
echo "Want to load $name.\n"; | |
throw new Exception("Unable to load $name. \n"); | |
} | |
try { | |
$obj = new NonLoadableClass(); | |
} catch (Exception $e) { | |
echo $e->getMessage(), "\n"; | |
} | |
Output: | |
Want to load NonLoadableClass. | |
Unable to load NonLoadableClass. | |
/** Static call **/ | |
function __autoload($name) { | |
echo "Want to load $name.\n"; | |
throw new Exception("Unable to load $name."); | |
} | |
try { | |
$obj = NonLoadableClass::a(); | |
} catch (Exception $e) { | |
echo $e->getMessage(), "\n"; | |
} | |
Output: | |
Want to load NonLoadableClass. | |
Fatal error: Class 'NonLoadableClass' not found in /var/www/test/a.php on line 11 Call Stack: 0.0002 641792 1. {main}() /var/www/test/a.php:0 | |
PHP Version 5.3.10-1ubuntu3.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment