note 65166 deleted from function.eval by bjori

From: Date: Tue, 25 Apr 2006 23:45:07 +0000
Subject: note 65166 deleted from function.eval by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-109707@lists.php.net to get a copy of this message
Note Submitter: Maresa Reason: in docs ---- 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>

« previous php.notes (#109707) next »