note 82448 added to function.php-check-syntax

From: Date: Fri, 11 Apr 2008 08:38:11 +0000
Subject: note 82448 added to function.php-check-syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-138178@lists.php.net to get a copy of this message
Nope guys.. to check the valid php you must do the followed: <? function checkPHP($source) { ob_start(); $sowhat = @eval('?>'.$source); $GLOBALS['sowhat'] = ob_get_contents(); ob_end_clean(); return $sowhat === NULL ? true : false; } $source = ' bla bla <?=$foo?> some stuff <? foreach ($somethins as $somethig) { // whatever }'; if (checkPHP($source)) { echo 'PHP code is correct'; } else { echo 'there are errors in your php: '.$GLOBALS['sowhat']; } ---- Server IP: 195.222.16.155 Probable Submitter: 88.196.124.149 ---- Manual Page -- http://www.php.net/manual/en/function.php-check-syntax.php Edit -- https://master.php.net/note/edit/82448 Del: integrated -- https://master.php.net/note/delete/82448/integrated Del: useless -- https://master.php.net/note/delete/82448/useless Del: bad code -- https://master.php.net/note/delete/82448/bad+code Del: spam -- https://master.php.net/note/delete/82448/spam Del: non-english -- https://master.php.net/note/delete/82448/non-english Del: in docs -- https://master.php.net/note/delete/82448/in+docs Del: other reasons-- https://master.php.net/note/delete/82448 Reject -- https://master.php.net/note/reject/82448 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#138178) next »