Syntax checking with create_function()

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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.



function lister_check_errors($errno, $errstr, $errfile, $errline)
    global $lister_embed_errors;
    $errdesc=array( FATAL=>'FATAL', ERROR=>'ERROR', WARNING=>'WARNING');
    if ($errtype=='') {
    $lister_embed_errors="$errtype [$errno]: $errstr<br />\n&nbsp; in line
function lister_check_syntax($code,$params)
    global $lister_embed_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

Re: Syntax checking with create_function()

Colin McKinnon wrote:

Quoted text here. Click to load it

Actually, it is throwing the errors - just not the way I thot it would. Back
to the drawing board.


Site Timeline