Re: using a variable to a function call

From: Date: Thu, 07 Mar 2002 15:10:37 +0000
Subject: Re: using a variable to a function call
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-87635@lists.php.net to get a copy of this message
isn't it the easiest way to do something like this: class test { function do ($var) { if ($var=='you') { $this->you_function(); } else { $this->me_function(); } } function you_function() { ... } function me_function() { ... } } $class = new test(); $class->do($var); Greets, Edward ----- Original Message ----- From: "Matt Williams" <lists@yewlands.com> To: <php-general@lists.php.net>; <PHP_UK@yahoogroups.com> Sent: Thursday, March 07, 2002 3:25 PM Subject: [PHP] using a variable to a function call > Hi all > > I get a variable that is set be a select box on a page. > I want to use this variable to call a function within a class that is based > on it's name. > > so if $var = "me" > > I want to call $class->me_function(); > > or if > > $var = "you" > > call > > $class->you_function(); > > How can I use the variable as part of the function name to call. > > TIA > > matt > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#87635) next »