Hi all,
The thing I'm doing just now uses create_function(). This works fine
provided I don't do something silly in the code I am trying to incorporate.
Is there any way I can check the syntax (like `php -l sript.php`). I know
that there is php_check_syntax() in PHP 5 but it needs a file & I'm still
on v 4.x.
I guess I could create a temporary file and try `php -l $tempfile` but
there's the complications of knowing what OS is on the machine where it's
running, also just because it has mod_php doesn't necessarily mean it has
the standalone.
I tried the code below, but it seems to only throw errors when you try to
execute the function which got created.
TIA,
C.
function lister_check_errors($errno, $errstr, $errfile, $errline)
{
global $lister_embed_errors;
$errdesc=array( FATAL=>'FATAL', ERROR=>'ERROR', WARNING=>'WARNING');
$errtype=$errdesc[$errno];
if ($errtype=='') {
$errtype="UNKNOWN";
}
$lister_embed_errors="$errtype [$errno]: $errstr<br />\n in line
$errline";
}
function lister_check_syntax($code,$params)
{
global $lister_embed_errors;
$lister_embed_errors='';
$errhandler=set_error_handler('lister_check_errors ');
if ($errhandler===false) {
return("set_error_handler() returned false");
}
// this doesn't detect the errors - you need to run the function
// to prove it! But this may modify the thing we are trying to list
$fn=create_function($params,$code);
set_error_handler($errhandler);
return($lister_embed_errors);
}