From: "Mark" <[EMAIL PROTECTED]> > I seem to learn something new every time you or Jennifer post (many > others as well). I never knew about variable functions. Cool!
You're welcome. I wouldn't recommend that solution exactly (an abstraction class would be better), but the functions do come in handy. For example, I use variable function in one of my validation classes. I have a main method called check() that is passed a "type" and a "value". The "type" must match a method in the class. The check() method does some default checking and then passes the $value to the $type() method for further checking... class Validate { function check($type,$value) { if($empty($value)) { return FALSE; } if(method_exists($this,$type)) { $retval = $this->$type($value); } return $retval; } function number($value) { if(preg_match('/[^0-9]/',$value)) { return FALSE; } else { return $value; } } } Where "number" is one of the types that'll be validated. $val = new Validate; $val->check('number',$_POST['somevalue']); $val->check('date',$_POST['somedate']); $val->check('phone',$_POST['phone_number']); etc... Where you'd have a phone() and date() method in the Validate class... I think that's the only place I've used variable-functions... or variable-methods, rather. :) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php