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_synta x() 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_er rors($errno, $errstr, $errfile, $errline)
{
global $lister_embed_e rrors;
$errdesc=array( FATAL=>'FATAL', ERROR=>'ERROR', WARNING=>'WARNI NG');
$errtype=$errde sc[$errno];
if ($errtype=='') {
$errtype="UNKNO WN";
}
$lister_embed_e rrors="$errtype [$errno]: $errstr<br />\n in line
$errline";
}
function lister_check_sy ntax($code,$par ams)
{
global $lister_embed_e rrors;
$lister_embed_e rrors='';
$errhandler=set _error_handler( 'lister_check_e rrors');
if ($errhandler=== false) {
return("set_err or_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_func tion($params,$c ode);
set_error_handl er($errhandler) ;
return($lister_ embed_errors);
}
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_synta x() 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_er rors($errno, $errstr, $errfile, $errline)
{
global $lister_embed_e rrors;
$errdesc=array( FATAL=>'FATAL', ERROR=>'ERROR', WARNING=>'WARNI NG');
$errtype=$errde sc[$errno];
if ($errtype=='') {
$errtype="UNKNO WN";
}
$lister_embed_e rrors="$errtype [$errno]: $errstr<br />\n in line
$errline";
}
function lister_check_sy ntax($code,$par ams)
{
global $lister_embed_e rrors;
$lister_embed_e rrors='';
$errhandler=set _error_handler( 'lister_check_e rrors');
if ($errhandler=== false) {
return("set_err or_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_func tion($params,$c ode);
set_error_handl er($errhandler) ;
return($lister_ embed_errors);
}
Comment