NYCPHP Meetup

NYPHP.org

[nycphp-talk] Eval question

LK lk613m at yahoo.com
Thu Oct 12 10:18:11 EDT 2006


<?php
  $x = 3;
  $y = 4;
  $calc_str = '$x * $y';
  eval("echo \"$calc_str\";");
?>

I want to evaluate the expression $x * $y (x times y). But when I run it thru the eval() function it returns "3 * 4" instead of "12". It seems to interpret * as a string instead of a multiplication operator. Any suggestions greatly appreciated

Leo Kokin





More information about the talk mailing list