ID: 22097
Comment by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux x86 2.4.18
PHP Version: 4.3.0
New Comment:
meant to type:
eval("\$errormessage .= eval(\"echo \\\"$$errortype\\\";\");");
in the above example.
Previous Comments:
------------------------------------------------------------------------
[2003-02-07 10:26:38] [EMAIL PROTECTED]
This doesn't work as expected. ($errormessage never actually gets set
for some reason.) But the double eval appears to work like it should.
I also tried:
eval("\$errormessage .= eval(\"echo \\\"$$errortype\\\";\";"); and it
still didn't work.
------------------------------------------------------------------------
[2003-02-06 17:30:53] [EMAIL PROTECTED]
CAUTION: The input field scrambled my input!
You have to use
- 3 slashes where it shows 7
- 1 slash where it shows 3
- 0 slash where it shows 1
------------------------------------------------------------------------
[2003-02-06 17:28:24] [EMAIL PROTECTED]
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 [EMAIL PROTECTED]
------------------------------------------------------------------------
[2003-02-06 16:43:28] [EMAIL PROTECTED]
$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