note 37487 deleted from function.eval by danbrown

From: Date: Sun, 17 May 2009 20:01:19 +0000
Subject: note 37487 deleted from function.eval by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155308@lists.php.net to get a copy of this message
Note Submitter: Mark Aufflick (mark at pumptheory dot com) ---- Based on the excellent example by olivier at revenu dot nom dot fr, I have extended it to allow the <?= ... ?> tagged style of embedded php code: <?php function eval_buffer($string) { ob_start(); eval("$string[2];"); $return = ob_get_contents(); ob_end_clean(); return $return; } function eval_print_buffer($string) { ob_start(); eval("print $string[2];"); $return = ob_get_contents(); ob_end_clean(); return $return; } function eval_html($string) { $string = preg_replace_callback("/(<\?=)(.*?)\?>/si", "eval_print_buffer",$string); return preg_replace_callback("/(<\?php|<\?)(.*?)\?>/si", "eval_buffer",$string); } ?>

« previous php.notes (#155308) next »