note 54646 deleted from function.eval by sniper

From: Date: Thu, 29 Dec 2005 09:15:05 +0000
Subject: note 54646 deleted from function.eval by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-100903@lists.php.net to get a copy of this message
Note Submitter: Casey Britt ---- I added a line to arnico's note posted here. Now, if you have a string that doesn't start with php tags or end with them, the function won't error out... <?php function eval_html($string) { $string = '<?php ?>' . $string . '<?php ?>'; // just in case string doesn't start and end with php tags. $string = preg_replace("/\?>(.*?)(<\?php|<\?)/si", "echo \"\\1\";", $string); $string = str_replace("<?php", "", $string); $string = str_replace("?>", "", $string); return eval($string); } ?>

« previous php.notes (#100903) next »