|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-02-06 16:43 UTC] tdrake at tymail dot 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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Feb 12 02:00:01 2026 UTC |
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.meant to type: eval("\$errormessage .= eval(\"echo \\\"$$errortype\\\";\");"); in the above example.