note 65166 added to function.eval

From: Date: Tue, 25 Apr 2006 22:46:13 +0000
Subject: note 65166 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-109704@lists.php.net to get a copy of this message
If you ever need a situation where you need to eval a string, but the string could be plain text that needs to be outputed or could be PHP code, I found that by adding "?>" to the beginning of text string will print whatever text after ?>. For example, $str1 = 'echo "<html><head><title>Untitled</title></head><body>The body</body></html>";'; // Note the "?>" characters is added in the beginning of the string. $str2 = '?><html><head><title>Untitled</title></head><body>The body</body></html>'; eval($str1); eval($str2); They both will output <html><head><title>Untitled</title></head><body>The body</body></html> ---- Server IP: 66.163.161.117 Probable Submitter: 67.126.148.190 ---- X-Spam-Status: No, hits=4.7 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_40_50,HTML_MESSAGE,HTML_TITLE_UNTITLED autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- http://master.php.net/note/edit/65166 Del: integrated -- http://master.php.net/note/delete/65166/integrated Del: useless -- http://master.php.net/note/delete/65166/useless Del: bad code -- http://master.php.net/note/delete/65166/bad+code Del: spam -- http://master.php.net/note/delete/65166/spam Del: non-english -- http://master.php.net/note/delete/65166/non-english Del: in docs -- http://master.php.net/note/delete/65166/in+docs Del: other reasons-- http://master.php.net/note/delete/65166 Reject -- http://master.php.net/note/reject/65166 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#109704) next »