note 88256 deleted from function.php-check-syntax by danbrown

From: Date: Sat, 17 Jan 2009 16:09:49 +0000
Subject: note 88256 deleted from function.php-check-syntax by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149368@lists.php.net to get a copy of this message
Note Submitter: admin at cmsdragon dot com ---- Ugh, people.. Why you are doing these heavy and weird stuff? <?php function is_php_ok($body) { ob_start(); $eval = eval('?><? if(0){?>'. $body.'?><? }?>'); $output = ob_get_contents(); ob_end_clean(); $eval===false ? $GLOBALS['phpERROR'] = str_replace('<b>Parse error</b>: parse error,','Parse error:',str_replace('<!--error--><br />','',substr($output,0,strpos($output,' in ')))).' '.substr($output,strpos($output,'on line')-5):''; return $eval===false?false:true; } $body = '<? checkme()?>sdfgsdgsf<?=fdf\'()?>bla blvv'; if (!is_php_ok($body)) { echo 'Whoops, errors were made: '.$GLOBALS['phpERROR']; } ?> Enjoy;) Simple and useful.

« previous php.notes (#149368) next »