#22097 [Opn->Bgs]: Eval fails to process this gem.
ID: 22097
Updated by: helly@php.net
Reported By: tdrake@tymail.com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux x86 2.4.18
PHP Version: 4.3.0
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You need to double evaluate.
$$errortype resolves to $invalid
evaluating resolves to the string containing $number.
That has to be evaluated as well.
Also why not use foreach and you can use eval()'s
return value. See below:
<?php
$errormessage = "";
$error["1231"] = "invalid";
$error["1255"] = "invalid_max";
$invalid = 'You did not choose a valid quantity for item number
$item.\n';
$invalid_min = 'You did not order the minimum amount for item
$item.\n';
$invalid_max = 'You ordered more than you were permitted for item
$item.\n';
//while (list($item, $errortype) = each($error)) {
foreach($error as $item=>$errortype) {
$errormessage .= eval("echo eval(\"echo
\\\"$$errortype\\\";\");");
}
echo $errormessage;
?
Send further questions please php-general@lists.php.net
Previous Comments:
------------------------------------------------------------------------
[2003-02-06 16:43:28] tdrake@tymail.com
$error["1231"] = "invalid";
$error["1255"] = "invalid_max";
$invalid = 'You did not choose a valid quantity for item number
$item.\n';
$invalid_min = 'You did not order the minimum amount for item
$item.\n';
$invalid_max = 'You ordered more than you were permitted for item
$item.\n';
while (list($item, $errortype) = each($error)) {
eval("\$errormessage .= \"$$errortype\";");
}
print $errormessage;
Eval prints the following:
You did not choose a valid quantity for item number $item.
You ordered more than you were permitted for item $item.
It should print this:
You did not choose a valid quantity for item number 1231.
You ordered more than you were permitted for item 1255.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22097&edit=1
Thread (5 messages)