note 22421 deleted from function.eval by nlopess

From: Date: Tue, 18 May 2004 13:39:27 +0000
Subject: note 22421 deleted from function.eval by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-69767@lists.php.net to get a copy of this message
Note Submitter: benjcarson at digitaljunkies dot ca ---- Really, the only thing you have to do if you want to parse a mixed html/php block string is: ob_start(); eval("?>" . $somestringwithcode . "<?php "); $output = ob_get_contents(); ob_end_clean(); And that's all! No need to search for "<?php" or "?>" (except to check if the string is even worth eval'ing, for efficiency's sake), nor do you have to use addslashes. This method works for parsed files, database fields, user input, whatever, and it's only *4* lines long... No need to be excessively complex here...

« previous php.notes (#69767) next »