brendan6 Posted February 26, 2008 Share Posted February 26, 2008 When i create a new instance of the exception class, it somehow knows the page uri and and the line number on which the exception was created. $e = new Exception("Oops"); echo $e; Outputs: exception 'Exception' with message 'Oops' in C:\wamp\www\test.php:3 Stack trace: #0 {main} How does it know the page which the instance of itself resides on? Link to comment https://forums.phpfreaks.com/topic/93035-the-magic-of-the-exception-class/ Share on other sites More sharing options...
rhodesa Posted February 26, 2008 Share Posted February 26, 2008 Because PHP is magical. If you would like to perform some magic yourself, check out the following special variables: __FILE__, __LINE__ http://us2.php.net/manual/en/language.constants.predefined.php For more fun, check out debug_backtrace() too! http://us2.php.net/manual/en/function.debug-backtrace.php Link to comment https://forums.phpfreaks.com/topic/93035-the-magic-of-the-exception-class/#findComment-476646 Share on other sites More sharing options...
brendan6 Posted February 26, 2008 Author Share Posted February 26, 2008 thanks buddy...the debug_backtrace() was what i was looking for! Link to comment https://forums.phpfreaks.com/topic/93035-the-magic-of-the-exception-class/#findComment-476670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.