PHP debugging

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Tyler

    #1

    PHP debugging

    PHP has some pretty funky error messages:

    "parse error, unexpected T_IF";
    "Parse error: parse error, unexpected T_CONSTANT_ENCA PSED_STRING";

    Humans often see these - shouldn't they be more human readable?

    ....and why are there no stack backtraces?

    When a problem arises, I am often interested in knowing where the
    problem code was called from.

    It seems as though - with PHP - I need third-party debugging tools if I
    want to access this information :-|
    --
    __________
    |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.
  • Tim Tyler

    #2
    Re: PHP debugging

    Tim Tyler <tim@tt1lock.or g> wrote or quoted:
    [color=blue]
    > PHP has some pretty funky error messages:
    >
    > "parse error, unexpected T_IF";
    > "Parse error: parse error, unexpected T_CONSTANT_ENCA PSED_STRING";
    >
    > Humans often see these - shouldn't they be more human readable?[/color]

    Heh: almost forgot one of my favourites:

    "Parse error: parse error, unexpected $end"

    For the benefit of PHP's authors, I'll translate that one into a more
    human-readable format myself:

    "The PHP parser unexpectedly encountered the end of the file - and it
    refuses to make any further effort to find out where the problem
    actually is - so you'll have to track the problem down yourself."
    --
    __________
    |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

    Comment

    • Spidah

      #3
      Re: PHP debugging

      Despite having been a programmer for many years, I have never been able to
      understand the need for such confusing error messages. Some of the messages
      in PHP are real shockers.

      It is as if some programmers get some sort of buzz out of making error
      messages as cryptic as humanly possible. Clearly the term "plain english" is
      not part of their vocabulary.

      Hamilton


      "Tim Tyler" <tim@tt1lock.or g> wrote in message news:I387n3.4vG @bath.ac.uk...[color=blue]
      > Tim Tyler <tim@tt1lock.or g> wrote or quoted:
      >[color=green]
      >> PHP has some pretty funky error messages:
      >>
      >> "parse error, unexpected T_IF";
      >> "Parse error: parse error, unexpected T_CONSTANT_ENCA PSED_STRING";
      >>
      >> Humans often see these - shouldn't they be more human readable?[/color]
      >
      > Heh: almost forgot one of my favourites:
      >
      > "Parse error: parse error, unexpected $end"
      >
      > For the benefit of PHP's authors, I'll translate that one into a more
      > human-readable format myself:
      >
      > "The PHP parser unexpectedly encountered the end of the file - and it
      > refuses to make any further effort to find out where the problem
      > actually is - so you'll have to track the problem down yourself."
      > --
      > __________
      > |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.[/color]


      Comment

      • CJ Llewellyn

        #4
        Re: PHP debugging

        "Spidah" <h.laughland@eg gstra.co.nz> wrote in message
        news:ortYc.1936 1$N77.763207@ne ws.xtra.co.nz.. .[color=blue]
        > Despite having been a programmer for many years, I have never been able to
        > understand the need for such confusing error messages. Some of the[/color]
        messages[color=blue]
        > in PHP are real shockers.
        >
        > It is as if some programmers get some sort of buzz out of making error
        > messages as cryptic as humanly possible. Clearly the term "plain english"[/color]
        is[color=blue]
        > not part of their vocabulary.[/color]

        Where as Empire Building and Job Creation are ;-)



        Comment

        • Tony Marston

          #5
          Re: PHP debugging

          What's wrong with PHP error messages? They tell you the script name, the
          line number, what was expected and what was found. What more do you want?
          Auto-correction?

          If you are not already using an IDE with an integrated debugger then you are
          a junior programmer indeed. Stop whingeing and start using proper tools.

          --
          Tony Marston

          This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL




          "Tim Tyler" <tim@tt1lock.or g> wrote in message news:I386tL.4F8 @bath.ac.uk...[color=blue]
          > PHP has some pretty funky error messages:
          >
          > "parse error, unexpected T_IF";
          > "Parse error: parse error, unexpected T_CONSTANT_ENCA PSED_STRING";
          >
          > Humans often see these - shouldn't they be more human readable?
          >
          > ...and why are there no stack backtraces?
          >
          > When a problem arises, I am often interested in knowing where the
          > problem code was called from.
          >
          > It seems as though - with PHP - I need third-party debugging tools if I
          > want to access this information :-|
          > --
          > __________
          > |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.[/color]


          Comment

          • Colin McKinnon

            #6
            Re: PHP debugging

            Tony Marston wrote:
            [color=blue]
            >
            > If you are not already using an IDE with an integrated debugger then you
            > are a junior programmer indeed. Stop whingeing and start using proper
            > tools.
            >[/color]

            So....if I go and install an IDE I'll be a better programmer ;).

            Silly me - I've been using all these stupid beginner tools like vi, sed and
            cvs. I even went to the trouble of writing my own error-handlers (which do
            things like reporting stack traces) with different versions for development
            and production (how do you implement error checking in production using an
            IDE?). Not to mention inserting instrumentation into my code.

            WRT the OP's questions:





            You might also find the lint option useful
            (http://uk.php.net/manual/en/features.commandline.php) although it's only a
            static check of the current file.

            Note that parse errors (like those you mentioned) are always fatal. I
            recently discovered that the create_function () seems to do strange things
            with error reporting (on a parse error execution of the main thread
            continues, but it seems to reports it via the default error handler)

            HTH

            C.

            Comment

            • Alvaro G. Vicario

              #7
              Re: PHP debugging

              *** Tony Marston escribió/wrote (Mon, 30 Aug 2004 10:42:20 +0100):[color=blue]
              > What's wrong with PHP error messages? They tell you the script name, the
              > line number, what was expected and what was found. What more do you want?
              > Auto-correction?[/color]

              "unexpected end of script" instead of "unexpected $end"
              "unexpected if() statement" instead of "unexpected T_IF"
              "expecting a variable name" instead of "expecting T_VARIABLE"

              Such things, I guess.


              --
              --
              -+ Álvaro G. Vicario - Burgos, Spain - ICQ 46788716
              +- http://www.demogracia.com (la web de humor para mayores de 100 años)
              ++ «Sonríe, que te vamos a hacer una foto para la esquela»
              --

              Comment

              • Tony Marston

                #8
                Re: PHP debugging


                "Colin McKinnon" <colin.deleteth is@andthis.mms3 .com> wrote in message
                news:cguvb7$ho9 $1$8302bc10@new s.demon.co.uk.. .[color=blue]
                > Tony Marston wrote:
                >[color=green]
                >>
                >> If you are not already using an IDE with an integrated debugger then you
                >> are a junior programmer indeed. Stop whingeing and start using proper
                >> tools.
                >>[/color]
                >
                > So....if I go and install an IDE I'll be a better programmer ;).[/color]

                You will be more productive if you use an IDE which includes a debugger
                instead of a simple text editor which does not. This will help you to track
                down and cure bugs faster which WILL make you a better programmer.

                If you don't use the right tools for the job then you will always be an
                amateur code-monkey.

                --
                Tony Marston

                This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL




                Comment

                • dbmethods

                  #9
                  Re: PHP debugging

                  Tony Marston wrote:[color=blue]
                  > "Colin McKinnon" <colin.deleteth is@andthis.mms3 .com> wrote in message
                  > news:cguvb7$ho9 $1$8302bc10@new s.demon.co.uk.. .
                  >[color=green]
                  >>Tony Marston wrote:
                  >>
                  >>[color=darkred]
                  >>>If you are not already using an IDE with an integrated debugger then you
                  >>>are a junior programmer indeed. Stop whingeing and start using proper
                  >>>tools.
                  >>>[/color]
                  >>
                  >>So....if I go and install an IDE I'll be a better programmer ;).[/color]
                  >
                  >
                  > You will be more productive if you use an IDE which includes a debugger
                  > instead of a simple text editor which does not. This will help you to track
                  > down and cure bugs faster which WILL make you a better programmer.
                  >[/color]

                  Which IDE you would recommend? Perfer run on Linux.
                  [color=blue]
                  > If you don't use the right tools for the job then you will always be an
                  > amateur code-monkey.
                  >[/color]

                  Comment

                  • Andrew DeFaria

                    #10
                    Re: PHP debugging

                    dbmethods wrote:
                    [color=blue]
                    > Tony Marston wrote:
                    >[color=green]
                    >> "Colin McKinnon" <colin.deleteth is@andthis.mms3 .com> wrote in message
                    >> news:cguvb7$ho9 $1$8302bc10@new s.demon.co.uk.. .
                    >>[color=darkred]
                    >>> Tony Marston wrote:
                    >>>
                    >>>> If you are not already using an IDE with an integrated debugger
                    >>>> then you are a junior programmer indeed. Stop whingeing and start
                    >>>> using proper tools.
                    >>>>
                    >>> So....if I go and install an IDE I'll be a better programmer ;).[/color]
                    >>
                    >> You will be more productive if you use an IDE which includes a
                    >> debugger instead of a simple text editor which does not. This will
                    >> help you to track down and cure bugs faster which WILL make you a
                    >> better programmer.[/color]
                    >
                    > Which IDE you would recommend? Perfer run on Linux.
                    >[color=green]
                    >> If you don't use the right tools for the job then you will always be
                    >> an amateur code-monkey.[/color]
                    >[/color]
                    Nonsense. All you need is a good editor and a good debugger! They need
                    not co-exist in the same window, they just need to be available - and
                    good. Tools are indeed tools. As such they should be separate and focus
                    on the issue of the problem they are designed to address. I don't have a
                    hammer/screwdriver/axe/drill combo - I have separates. Each tool is good
                    at what it was designed to do and these tools can be used together if
                    need be.

                    It is not really that difficult to edit in your editor and drop into a
                    command window to debug or a browser or whatever. Indeed it keeps you in
                    touch with how all of this works together. IDEs cloud that issue and
                    often people do not know how to do anything except with their particular
                    IDE with it's particular extensions. True masters use their tools and
                    apply them to different problems. There is saying about this, "If all
                    you have is a hammer then all of your problems look like nails!". But a
                    true master will use different tools, each good at what it does, in
                    ingenious ways to solve way more problems than the hammer master! And,
                    he'll know why they worked or why the particular tool is not suited for
                    the task at hand.

                    Comment

                    • Jasper Bryant-Greene

                      #11
                      Re: PHP debugging

                      Andrew DeFaria wrote:
                      [color=blue][color=green]
                      >> Which IDE you would recommend? Perfer run on Linux.[/color][/color]

                      For coding, on Linux I use nano in the console and Kate/Kwrite in KDE.
                      In Windows, Notepad.

                      For debugging, upload to a testing Apache server (can even be on the
                      local machine) and hit the page in Mozilla Firefox.

                      Simple, and no bloated IDEs needed.

                      --
                      Jasper Bryant-Greene
                      Cabbage Promotions

                      Comment

                      • Tony Marston

                        #12
                        Re: PHP debugging


                        "dbmethods" <dbmethods@nosp am.com> wrote in message
                        news:9KQYc.2770 2$Es2.10186114@ news4.srv.hcvln y.cv.net...[color=blue]
                        > Tony Marston wrote:[color=green]
                        >> "Colin McKinnon" <colin.deleteth is@andthis.mms3 .com> wrote in message
                        >> news:cguvb7$ho9 $1$8302bc10@new s.demon.co.uk.. .
                        >>[color=darkred]
                        >>>Tony Marston wrote:
                        >>>
                        >>>
                        >>>>If you are not already using an IDE with an integrated debugger then you
                        >>>>are a junior programmer indeed. Stop whingeing and start using proper
                        >>>>tools.
                        >>>>
                        >>>
                        >>>So....if I go and install an IDE I'll be a better programmer ;).[/color]
                        >>
                        >>
                        >> You will be more productive if you use an IDE which includes a debugger
                        >> instead of a simple text editor which does not. This will help you to
                        >> track down and cure bugs faster which WILL make you a better programmer.
                        >>[/color]
                        >
                        > Which IDE you would recommend? Perfer run on Linux.[/color]

                        I develop on Windows, not Linux, so I use PHPEdit from


                        For others I suggest you search google with


                        --
                        Tony Marston

                        This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL




                        Comment

                        • Tony Marston

                          #13
                          Re: PHP debugging


                          "Andrew DeFaria" <Andrew@DeFaria .com> wrote in message
                          news:ffbd$4133e 816$c09cfcf$195 14@msgid.megane wsservers.com.. .[color=blue]
                          > dbmethods wrote:
                          >[color=green]
                          >> Tony Marston wrote:
                          >>[color=darkred]
                          >>> "Colin McKinnon" <colin.deleteth is@andthis.mms3 .com> wrote in message
                          >>> news:cguvb7$ho9 $1$8302bc10@new s.demon.co.uk.. .
                          >>>
                          >>>> Tony Marston wrote:
                          >>>>
                          >>>>> If you are not already using an IDE with an integrated debugger then
                          >>>>> you are a junior programmer indeed. Stop whingeing and start using
                          >>>>> proper tools.
                          >>>>>
                          >>>> So....if I go and install an IDE I'll be a better programmer ;).
                          >>>
                          >>> You will be more productive if you use an IDE which includes a debugger
                          >>> instead of a simple text editor which does not. This will help you to
                          >>> track down and cure bugs faster which WILL make you a better programmer.[/color]
                          >>
                          >> Which IDE you would recommend? Perfer run on Linux.
                          >>[color=darkred]
                          >>> If you don't use the right tools for the job then you will always be an
                          >>> amateur code-monkey.[/color]
                          >>[/color]
                          > Nonsense. All you need is a good editor and a good debugger! They need not
                          > co-exist in the same window, they just need to be available - and good.[/color]

                          I prefer an IDE with an integrated debugger. A primitive editor and a
                          separate debugger just slow me down and lower my productivity rate. That is
                          not good..
                          [color=blue]
                          > Tools are indeed tools. As such they should be separate and focus on the
                          > issue of the problem they are designed to address. I don't have a
                          > hammer/screwdriver/axe/drill combo - I have separates. Each tool is good
                          > at what it was designed to do and these tools can be used together if need
                          > be.
                          >
                          > It is not really that difficult to edit in your editor and drop into a
                          > command window to debug or a browser or whatever. Indeed it keeps you in
                          > touch with how all of this works together. IDEs cloud that issue[/color]

                          Cloud the issue how exactly?
                          [color=blue]
                          > and often people do not know how to do anything except with their
                          > particular IDE with it's particular extensions.[/color]

                          So what? A good programmer should be able to switch from one IDE to another
                          relatively easily.
                          [color=blue]
                          > True masters use their tools and apply them to different problems. There
                          > is saying about this, "If all you have is a hammer then all of your
                          > problems look like nails!". But a true master will use different tools,
                          > each good at what it does, in ingenious ways to solve way more problems
                          > than the hammer master! And, he'll know why they worked or why the
                          > particular tool is not suited for the task at hand.[/color]

                          Once you have used an IDE with an integrated debugger you will realise that
                          switching back to a simple text editor and a command line debugger is a
                          retrograde step. They may both get the job done, but one is faster and
                          therefore better.

                          I rest my case.

                          --
                          Tony Marston

                          This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL




                          Comment

                          • Daniel Tryba

                            #14
                            Re: PHP debugging

                            Tony Marston <tony@nospam.de mon.co.uk> wrote:[color=blue][color=green]
                            >> Nonsense. All you need is a good editor and a good debugger! They need not
                            >> co-exist in the same window, they just need to be available - and good.[/color]
                            >
                            > I prefer an IDE with an integrated debugger. A primitive editor and a
                            > separate debugger just slow me down and lower my productivity rate. That is
                            > not good..[/color]

                            slow _you_ down. I have yet to find an IDE that has an editor as
                            powerful as vim. But then again there are people who hate vi(m).

                            [...][color=blue]
                            > Once you have used an IDE with an integrated debugger you will realise that
                            > switching back to a simple text editor and a command line debugger is a
                            > retrograde step. They may both get the job done, but one is faster and
                            > therefore better.[/color]

                            I tried Zend studio once, it' s debugger is great. The editor was IMHO
                            horrible. As long as there are no problems in code/server, a "simple
                            editor" is fasted, in the case of bugs in complex datasctructures a
                            decent debugger is needed. But there is absolutly no need to have them
                            integrated.

                            But enlighten me, what IDE (for PHP) should I take a look at?
                            [color=blue]
                            > I rest my case.[/color]

                            You failed to deliver facts, only opinions (just like I expressed my
                            own above)

                            --

                            Daniel Tryba

                            Comment

                            • Rob Allen

                              #15
                              Re: PHP debugging

                              In message <9KQYc.27702$Es 2.10186114@news 4.srv.hcvlny.cv .net>, dbmethods
                              <dbmethods@nosp am.com> writes[color=blue]
                              >Which IDE you would recommend? Perfer run on Linux.[/color]

                              Zend Studio.

                              Useful features (as in most IDEs):
                              * code completion - tooltip includes phpdoc info about function.
                              * debugger.
                              * press F1 to get help on a php function.
                              * "go to source of this function" (i.e ctags ).
                              * grouping of files into "projects".
                              * find in project.

                              Things I dislike:
                              * no "strip trailing whitespace" on save.
                              * ctrl+tab for switching open files doesn't use a "stack" of tabs.
                              * no keyboard shortcut for "open file under cursor".
                              * no keyboard shortcut for "go to source of this function".
                              * tab line for open files becomes multi-line if too many files are
                              opened.


                              It's free for personal use and not especially expensive if you are
                              making money from your PHP coding :)

                              --
                              Rob...

                              Comment

                              Working...