note 59338 deleted from function.eval by sp

From: Date: Sun, 22 Jan 2006 09:02:01 +0000
Subject: note 59338 deleted from function.eval by sp
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-102229@lists.php.net to get a copy of this message
Note Submitter: djogopatrao at gmail dot com ---- As a matter of fact, you don't need to use eval() if you want to call a function whose name is in some variable, say $function. You just need to call $function(...); An obvious example (with some interesting implications): <? $repository = new Repository(); $function = $_REQUEST[operation]; echo $repository->$function( $_REQUEST[id] ); ?> One must put all functions that can be called at the class Repository. It's not a good idea to do <? $_REQUEST[operation]() ?> or the user can run anything he wants to (my own experience here) =)

« previous php.notes (#102229) next »