note 45335 deleted from function.eval by tomsommer
| From: | tomsommer@php.net | Date: | Thu, 02 Sep 2004 20:22:10 +0000 |
| Subject: | note 45335 deleted from function.eval by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75953@lists.php.net to get a copy of this message | ||
Note Submitter: misza at weblab dot com dot pl
----
eval is also usefull when you try to invoke static method from class which name you have got on a
variable. For example:
class AAA {
function validateInput($param)
{ return "AAA::validateInput($param)"; }
}
$parametry = 'oto parametr';
$nazwa_klasy = 'AAA';
eval("\$result = {$nazwa_klasy}::validateInput(\$parametry);");
//$result = ${nazwa_klasy}::validateInput($parametry); // this does not work
echo $result;
I have not found anything bettar then this (thanks to metempsychoza).
misza