note 30992 added to function.eval
| From: | arne dot hartherz at gmx dot net | Date: | Sat, 05 Apr 2003 17:53:44 +0000 |
| Subject: | note 30992 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46263@lists.php.net to get a copy of this message | ||
It almost drove me mad getting the same error over and over again ("unexpected $ in ...... :
eval()'d line 1") when using the method from above (the one by Bart Koelman) to make my
globals available in a function.
The problem was simple: one of my variables contained quotes...
Try using this instead -- it works fine as I can see till now:
---cut---here---
reset ($GLOBALS);
while (list ($key, $val) = each ($GLOBALS))
{
$val = str_replace('"','\"',$val);
eval("\$" . "\$key = \"$val\";");
}
---cut---here---
Regards,
Arne
--
http://www.php.net/manual/en/function.eval.php
http://master.php.net/manage/user-notes.php?action=edit+30992
http://master.php.net/manage/user-notes.php?action=delete+30992
http://master.php.net/manage/user-notes.php?action=reject+30992