enridp Posted March 29, 2011 Share Posted March 29, 2011 Hi ! I was seeing the Exception class defined in basic.php and I found that all the methods are final and without body: final public function getMessage () {} But if I call MyCustomException->getMessage() I get the message. How does it works?? Quote Link to comment https://forums.phpfreaks.com/topic/232113-exception-class-in-php-is-this-magic/ Share on other sites More sharing options...
trq Posted March 30, 2011 Share Posted March 30, 2011 The class likely extends the built in Exception class. Quote Link to comment https://forums.phpfreaks.com/topic/232113-exception-class-in-php-is-this-magic/#findComment-1193947 Share on other sites More sharing options...
enridp Posted March 30, 2011 Author Share Posted March 30, 2011 I didn't understand you thorpe, I'm talking about Exception class, the built in PHP class. That class is defined in basic.php, and the method is defined as: final public function getMessage () {} How can it works then? Even in php.net there's a comment at the end about that: http://www.php.net/manual/es/class.exception.php#84617 Â If the method has not definition why when we use ->getMessage() we get the message? Â Quote Link to comment https://forums.phpfreaks.com/topic/232113-exception-class-in-php-is-this-magic/#findComment-1193960 Share on other sites More sharing options...
trq Posted March 30, 2011 Share Posted March 30, 2011 I didn't understand you thorpe, I'm talking about Exception class, the built in PHP class. That class is defined in basic.php, and the method is defined as: Â As you just stated. The Exception class is built into PHP so it's not defined in any basic.php file. The class you are looking at within basic.php likely extends the built in PHP Exception class. Quote Link to comment https://forums.phpfreaks.com/topic/232113-exception-class-in-php-is-this-magic/#findComment-1193976 Share on other sites More sharing options...
enridp Posted March 30, 2011 Author Share Posted March 30, 2011 Ah, OK, I was pressing F3 in Zend Studio and that take me to basic.php. Is possible to see the official PHP code for Exception Class? Quote Link to comment https://forums.phpfreaks.com/topic/232113-exception-class-in-php-is-this-magic/#findComment-1193985 Share on other sites More sharing options...
trq Posted March 30, 2011 Share Posted March 30, 2011 The Exception class is (like the rest of PHP) written in C. Why do you need to see the code? The manual tells you what it provides. Quote Link to comment https://forums.phpfreaks.com/topic/232113-exception-class-in-php-is-this-magic/#findComment-1193996 Share on other sites More sharing options...
enridp Posted March 30, 2011 Author Share Posted March 30, 2011 it was just curiosity, I was pressing F3 and I found that file (basic.php) which confused me. Thanks thorpe ! Quote Link to comment https://forums.phpfreaks.com/topic/232113-exception-class-in-php-is-this-magic/#findComment-1194348 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.