note 108908 added to function.eval

From: Date: Sun, 03 Jun 2012 22:30:26 +0000
Subject: note 108908 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-188388@lists.php.net to get a copy of this message
Good way to intercept parse error in eval: <?php // First make sure that any errors which happened before will not be reported @trigger_error(""); $code = 'whatever causing parse error'; $result = eval($code); $error = error_get_last(); // We only check for PHP Parse error in the begging of the line. Other messages containing words "PHP Parse error" are ignored. if (substr($error["message"], "PHP Parse error") === 0) { echo "Parse error: " . $code; } ?> PS: it will work only in PHP >5.2.0 ---- Server IP: 69.147.83.197 Probable Submitter: 150.101.235.251 ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- https://master.php.net/note/edit/108908 Del: integrated -- https://master.php.net/note/delete/108908/integrated Del: useless -- https://master.php.net/note/delete/108908/useless Del: bad code -- https://master.php.net/note/delete/108908/bad+code Del: spam -- https://master.php.net/note/delete/108908/spam Del: non-english -- https://master.php.net/note/delete/108908/non-english Del: in docs -- https://master.php.net/note/delete/108908/in+docs Del: other reasons-- https://master.php.net/note/delete/108908 Reject -- https://master.php.net/note/reject/108908 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#188388) next »