Re: note 9558 added to eval

From: Date: Sat, 11 Nov 2000 00:42:51 +0000
Subject: Re: note 9558 added to eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-7589@lists.php.net to get a copy of this message
This is a problem w/ your quoting and concatenation, and the expected behavior. Elsewhere in the manual it is clearly stated that vairables inside a double quoted string are parsed and interpolated, and if you do not need/want that, to escape the appropriate characters or use single quotes. Also, it is safer to use the concatenation operator, in particular when you have complex variable references (arrays of arrays, properties of objects, variable variables, etc.), so the line should've read: eval ($hdl.' ($var);'); This is well know, and for examples of general serialization of code to a database, look at PHPLIB, one of the first and better known libraries of accesory/utility classes. Your note has been removed. --- 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. > > http://www.php.net/manual/function.eval.php > > > -- > PHP Notes Mailing List (http://www.php.net/) > To unsubscribe, e-mail: > php-notes-unsubscribe@lists.php.net > For additional commands, e-mail: > php-notes-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > ===== --- Jesus M. Castagnetto (jcastagnetto@yahoo.com) __________________________________________________ Do You Yahoo!? Thousands of Stores. Millions of Products. All in one Place. http://shopping.yahoo.com/

« previous php.notes (#7589) next »