note 49626 added to function.eval

From: Date: Thu, 03 Feb 2005 10:38:25 +0000
Subject: note 49626 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-84426@lists.php.net to get a copy of this message
To use eval as a template parser, use the following: ob_start(); @eval('?>'.$textbody); $textbody = ob_get_contents(); ob_end_clean(); With a suitable error handling function: function myerrorhandler($errno, $errmsg, $filename, $linenum) { # Obey 'no error reporting' ('@'), but save the error if (error_reporting() == 0) $global_errors = rtrim($errmsg); else die("$filename:$linenum: Error $errno: $errmsg"); } error_reporting(E_ALL); set_error_handler('myerrorhandler'); you can display any warnings as well in the texts. ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49626 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49626&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49626&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49626&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49626&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49626&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49626&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84426) next »