note 16872 added to function.eval

From: Date: Fri, 16 Nov 2001 15:11:45 +0000
Subject: note 16872 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-20926@lists.php.net to get a copy of this message
If you are getting a parse error with eval() and have a string like this: $test = 'success'; $string = 'This is a "$test"'; You'll have to add slashes, do the eval() and then remove the slashes, like so: $test = 'success'; $string = 'This is a "$test"'; echo $string; $string = addslashes($string); eval("\$string = \"$string\";"); $string = stripslashes($string); echo $string; Hope this helps someone -- I know it would have helped me :) -- http://www.php.net/manual/en/function.eval.php http://master.php.net/manage/user-notes.php?action=edit+16872 http://master.php.net/manage/user-notes.php?action=delete+16872 http://master.php.net/manage/user-notes.php?action=reject+16872

« previous php.notes (#20926) next »