Jump to content

Recommended Posts

I am guessing by magic method you mean you are using __call to respond to calls for getSettings().  If that's the case, then you cannot use method_exists to check if that "method" is defined because PHP has no way of actually checking what __call handles and what it doesn't.  You'd have to provide your own means of determining if that "method" is defined.  One option is to just call it and have __call throw an exception if it's not handled.  You can then catch that exception and handle it however you want.

I think a better solution would be to abandon __call entirely and design your code in a way that getSettings is a real method.  Perhaps you could define it as part of an interface then check whether or not your object implements that interface.

Link to comment
https://forums.phpfreaks.com/topic/311458-method_exist/#findComment-1581289
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.