note 9558 deleted from function.eval by jimw

From: Date: Sat, 08 Dec 2001 23:23:12 +0000
Subject: note 9558 deleted from function.eval by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22317@lists.php.net to get a copy of this message
[Editor's note: I am including here part of the (removed) comment by kenny@yellowzone.com to which this note makes reference: --- kenny@yellowzone.com wrote: > The following tooks me an hour to figure out: > > If you have a variable $hdl contains the > name of the function that you want to > execute, and you have the variable $var > contains the values that need to be passed into the > function in $hdl, the > way to execute them is: > > eval ("$hdl (\$var);"); > > So, you can have functions's names saved > in a database, and pass in values come from > somewhereelse, and dynamically choose the right > functions to process the input data. This is the expected behavior due to the parsing/interpolation of variables referenced in a doble quoted string, if you do need to avoid the parsing, you need to escape the variable name (as kenny@yellowzone.com example does), or simple concatenate the string using single quotes, e.g.: eval ($hdl.' ($var);'); Nothing new here that is not already discussed in the manual elsewhere. ] ...or you can simply do this: $hdl($var); ...provided $hdl is a user-defined function, and one of PHP's built-in functions.

« previous php.notes (#22317) next »