Jump to content

Exception class in PHP (is this magic?)


enridp

Recommended Posts

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??

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.