Jump to content

Creating functions on the fly


Turbowaffle

Recommended Posts

I want to be able to intercept function calls that are to non-existent functions, and optionally create a function of that name. I want to do something like:

foo->getBar();

getBar doesn't exist, but I want to intercept the error generated to determine if I want to create the getBar function using the create_function or not.  I almost positive I read how to do this in PHP, but I can't seem to find it now.
Link to comment
Share on other sites

why would there be non-existent functions called if you didn't mispell/misname them yourself?

I guess I'm just asking for a little more in depth scenario.
you say and error is returned and that only happens when the coder makes and error...most of the time

so I'm guessing you're trying to allow open source something


EDIT:
nevermind
I got beat

Very interesting article BTW...I feel so inspired now
Link to comment
Share on other sites

Basically, I'm creating a wrapper that calls one of a dozen or so functions available through a CGI via different 'command' strings. So, rather than write a dozen functions, or something like foo->callCgiMethod(xyz), foo->xyz() will work if I add a check in _call to see if it's one of the availble commands and then create it. I could also go through the array and create_function each of them, but I figured it'd use fewer resources to just create the function I need. 
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.