Forum Moderators: coopster

Message Too Old, No Replies

best way to debug php when you have a syntax error?

I've looked at the error handling, but it doesn't seem help

         

pixeltierra

5:31 am on Nov 28, 2006 (gmt 0)

10+ Year Member



Whenever we miss a ';' or a '}' in php, it shows a blank white screen. What is the best way to find where the error is?

pixeltierra

6:19 am on Nov 28, 2006 (gmt 0)

10+ Year Member



Ok, I've descovered the cause of my woes was this ini setting: ignore_repeated_errors on

It seems when I change the error_reporting() the setting above would cause strange behavior, because it wouldn't give me the same error(s) twice in row, even on different page loads. I thought I was going crazy.

All is better now. Thanks.

eelixduppy

11:29 am on Nov 28, 2006 (gmt 0)



Glad you solved it! Here's a related thread [webmasterworld.com] if you are up to reading it. ;)

henry0

11:42 am on Nov 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When going live don't forget turning off error_reporting() at your .ini level.
Errors reporting: on, could give away too many information.

swa66

11:50 am on Nov 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For finding syntax errors:

command line php can:

  • do syntax check only with the "-l" switch
  • specify alternate php-ini with the "-c <file>" option or use "-n" not to use a php.ini at all.

    e.g.:

    $ cat /tmp/t
    <?
    echo test
    echo test
    ?>

    $ php -ln /tmp/t

    Parse error: parse error, unexpected T_ECHO, expecting ',' or ';' in /tmp/t on line 3
    Errors parsing /tmp/t
  •