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? Quote Link to comment 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 Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.