[nycphp-talk] Eval question
LK
lk613m at yahoo.com
Thu Oct 12 11:18:32 EDT 2006
The reason I used literal string is because that's how it is used on the official PHP site at http://www.php.net/manual/en/function.eval.php
Also, in my haste I supplied a slightly incorrect example (apologies), it shoul be:
<?php
$calc_str = '$x * $y';
$x = 3;
$y = 4;
eval("echo \"$calc_str\";");
?>
Where the calc_str comes first at design time, while $x and $y are determined at run time. With this restriction using double quotes "$x * $y" in the proposed solution below will not work either.
Leo
----- Original Message ----
From: Jon Baer <jonbaer at jonbaer.com>
To: NYPHP Talk <talk at lists.nyphp.org>
Sent: Thursday, October 12, 2006 10:26:32 AM
Subject: Re: [nycphp-talk] Eval question
You are quoting w/ a literal string ... try ...
<?php
$x = 3;
$y = 4;
$calc_str = "$x * $y";
eval("echo $calc_str;");
?>
- Jon
On Oct 12, 2006, at 10:18 AM, LK wrote:
<?php
$x = 3;
$y = 4;
$calc_str = '$x * $y';
eval("echo \"$calc_str\";");
?>
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20061012/23dcaf11/attachment.html>
More information about the talk
mailing list