Picking Up Parsing etc. Errors in PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alan M Dunsmuir

    Picking Up Parsing etc. Errors in PHP

    I'm using Kate in Linux (and UltraEdit when I have to drop back into
    Windows) for writing my PHP code. As a independent, self-employed
    developer, I cannot afford a commercial IDE for PHP such as is provided
    by Zend.

    I'm running PHP (with Apache) on my own machine for my development work.

    Is there some way ("strict" settings in the php.ini file, or whatever)
    by which I can cut down the time I'm wasting searching for, and
    recovering from, silly syntax errors in the code I write?

    I've just spend a day, for example, finding a complex two-condition 'if'
    statement where I'd simply forgotten to supply the outermost pair of
    brackets. The only symptom I was getting was a total absence of HTML
    output to the page, and my only debugging "tool" was the provision of
    'echo' statements at various places down the PHP code, coupled with the
    total commenting out of all PHP code beyond the one currently being tried.

    If anybody knows of a free- or shareware PHP syntax checking tool for
    Linux, I'd be grateful if they could let me know.
  • =?iso-8859-1?Q?=C1lvaro?= G. Vicario

    #2
    Re: Picking Up Parsing etc. Errors in PHP

    *** Anonymous escribió/wrote (Fri, 08 Feb 2008 19:38:54 +0100):
    Check your php.ini for the following:
    >
    error_reporting = E_ALL
    Or even better (for PHP 5):

    error_reporting = E_ALL | E_STRICT


    --
    -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    ++ Mi sitio sobre programación web: http://bits.demogracia.com
    +- Mi web de humor austrohúngaro: http://www.demogracia.com
    --

    Comment

    • Rik Wasmus

      #3
      Re: Picking Up Parsing etc. Errors in PHP

      On Fri, 08 Feb 2008 18:58:27 +0100, Alan M Dunsmuir
      <alan@moonrake. demon.co.ukwrot e:
      I'm using Kate in Linux (and UltraEdit when I have to drop back into
      Windows) for writing my PHP code. As a independent, self-employed
      developer, I cannot afford a commercial IDE for PHP such as is provided
      by Zend.
      >
      I'm running PHP (with Apache) on my own machine for my development work.
      >
      Is there some way ("strict" settings in the php.ini file, or whatever)
      by which I can cut down the time I'm wasting searching for, and
      recovering from, silly syntax errors in the code I write?
      >
      I've just spend a day, for example, finding a complex two-condition 'if'
      statement where I'd simply forgotten to supply the outermost pair of
      brackets. The only symptom I was getting was a total absence of HTML
      output to the page, and my only debugging "tool" was the provision of
      'echo' statements at various places down the PHP code, coupled with the
      total commenting out of all PHP code beyond the one currently being
      tried.
      >
      If anybody knows of a free- or shareware PHP syntax checking tool for
      Linux, I'd be grateful if they could let me know.
      Aside from the allready mentioned method to just run PHP and check the
      errors, here's one that I use with my favourite editor: php -l
      /path/to/file/name.php will ONLY do a syntax check, and report the result.
      No more having to go through the webserver, run the entire code, perhaps
      endlessly type urls/refresh windows. Just a simple key combination in the
      editor here does it.
      --
      Rik Wasmus

      Comment

      • axlq

        #4
        Re: Picking Up Parsing etc. Errors in PHP

        In article <op.t571m4gx5bn juv@metallium.l an>,
        Rik Wasmus <luiheidsgoeroe @hotmail.comwro te:
        ><alan@moonrake .demon.co.ukwro te:
        >Is there some way ("strict" settings in the php.ini file, or whatever)
        >by which I can cut down the time I'm wasting searching for, and
        >recovering from, silly syntax errors in the code I write?
        >
        >Aside from the allready mentioned method to just run PHP and check the
        >errors, here's one that I use with my favourite editor: php -l
        >/path/to/file/name.php will ONLY do a syntax check, and report the result.
        That's a good suggestion. It should also catch instances where you use
        a variable before it's initialized.

        To debug online, I have an initialization script that is included
        at the top of every single script I have. Among other things, the
        initialization has the following lines:

        if (SHOW_WARN) { // This is set in my config.php script
        $errlog = "/home/my_account/some_path/error.log"; // error log file
        if (file_exists($e rrlog)) unlink($errlog) ; // remove prev. error log
        ini_set('displa y_errors', false); // prevent pre-header abort
        ini_set('log_er rors', true); // enable error logging
        ini_set('error_ log', $errlog); // set error log file
        error_reporting (E_ALL); // report all errors
        }

        ....and then at the bottom of my master page template I simply
        display the error log if it exists, within <pre>...</pretags.

        This method is necessary when one can't use php -l. One can't use
        php -l when the execution of your script depends on cookies, login
        data and other session-related data, responses from FORM submissions,
        etc.

        -A

        -A

        Comment

        Working...