note 22421 added to function.eval

From: Date: Mon, 17 Jun 2002 22:25:21 +0000
Subject: note 22421 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-31953@lists.php.net to get a copy of this message
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... -- http://www.php.net/manual/en/function.eval.php http://master.php.net/manage/user-notes.php?action=edit+22421 http://master.php.net/manage/user-notes.php?action=delete+22421 http://master.php.net/manage/user-notes.php?action=reject+22421

« previous php.notes (#31953) next »