Jump to content


Photo

Dynamic function names in classes?


  • Please log in to reply
No replies to this topic

#1 aaronvegh

aaronvegh
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 May 2006 - 01:41 PM

I'm trying to write a class that has variable (dynamic) function names. Here's some code:


/* Construct the function name that will be called to validate the data */
     $func = $key."_validate";
/* Check to see if the validation function exists for this form element. */
     if(function_exists(eval("\$this->".$func.";"))) {
        etc...

my best attempt is to use eval(), but it's not working; you can echo out the eval statement and get $this->functionname, but apparently the statement is evaluated after compile time or something, because it doesn't work.

Anyone know how to get this to work?

Thanks,
Aaron.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users