Jump to content

Recommended Posts

I was working on this template and took me almost an hour to spot this single mistake and it does get annoying.

Human error happens.. anyone know of a software I can work with to output any mistakes I make?

 

Template I'm working with just goes on and on and I think I am going to need this. It's hours of work.

You can see screenshot what I mean, there is a 1 mistake and it's not always easy to spot them.

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/207591-quick-way-to-spot-syntax-error/
Share on other sites

Get an editor with syntax highlighting/checking.  It will highlight the code a certain way if if there is a syntax error it will either change the highlighting so that it is obvious or it may actually underline/highlight the error.  Also, from a command line you can do 'php -l filename.php'.

There isn't a computer program that can find exactly what syntax the programmer left out or put in the wrong place because that would require the program to be able to read minds to learn what the programmer intended. For example, if you left out a closing quote on a string. The computer cannot determine that you didn't want the rest of the code to be part of the string and where you intended the closing quote to go because a multi-line string is valid syntax, just like a multi-line statement is correct syntax, as are multiple statements on one line.

 

The reason why language parsers often report a syntax error on a line following the line where the actual wrong syntax is located at is because the only thing computers can do (without mind reading ability) is detect when something is found in a location where it does not belong. Computers cannot tell what or where the programmer left something out or what or where he put something in the wrong place.

 

Only the programmer who is writing the code can determine what he intended and where the correct syntax elements belong and it is his responsibility to learn the correct syntax in the first place and use it where he intends it to be.

 

The analogy is writing a letter and you leave out a comma, a period, or use the wrong form of a word (homonym) that changes the meaning of what you have written. A dumb computer could proof read it but about all it could find is that you perhaps wrote a run-on sentence. It would not be able to find and fix the errors in it without knowing the meaning of what the author intended.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.