note 66631 added to function.eval
| From: | burninleo at gmx dot net | Date: | Thu, 25 May 2006 12:51:00 +0000 |
| Subject: | note 66631 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112193@lists.php.net to get a copy of this message | ||
The only way to retreive information on parse errors in eval'd code seems to be the output
buffering.
<?PHP
// Append a return true to php-code to check on errors
$code.= "\nreturn true;";
// Send any output to buffer
ob_start();
// Do eval()
$check = eval($code);
$output = ob_get_contents();
ob_end_clean();
// Send output or report errors
if ($check === true) {
echo $output;
} else {
// Manually parse output for errors and
// generate usable information for the user
// especially content of error-lines.
$pattern = '/^\s*Parse error\s*:(.+) in (.+) on line (\d+)\s*$/m';
etc ...
}
----
Server IP: 212.124.37.9
Probable Submitter: 84.57.48.150
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit -- http://master.php.net/note/edit/66631
Del: integrated -- http://master.php.net/note/delete/66631/integrated
Del: useless -- http://master.php.net/note/delete/66631/useless
Del: bad code -- http://master.php.net/note/delete/66631/bad+code
Del: spam -- http://master.php.net/note/delete/66631/spam
Del: non-english -- http://master.php.net/note/delete/66631/non-english
Del: in docs -- http://master.php.net/note/delete/66631/in+docs
Del: other reasons-- http://master.php.net/note/delete/66631
Reject -- http://master.php.net/note/reject/66631
Search -- http://master.php.net/manage/user-notes.php