karimali831 Posted July 13, 2010 Share Posted July 13, 2010 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] Quote Link to comment https://forums.phpfreaks.com/topic/207591-quick-way-to-spot-syntax-error/ Share on other sites More sharing options...
AbraCadaver Posted July 13, 2010 Share Posted July 13, 2010 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'. Quote Link to comment https://forums.phpfreaks.com/topic/207591-quick-way-to-spot-syntax-error/#findComment-1085370 Share on other sites More sharing options...
gwolgamott Posted July 13, 2010 Share Posted July 13, 2010 Sometimes when syntax is right, but wrong syntax for what you want thus running and not being caught by a good editor. Nothing beats the good ol' echoing test method at different areas. Quote Link to comment https://forums.phpfreaks.com/topic/207591-quick-way-to-spot-syntax-error/#findComment-1085376 Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2010 Share Posted July 13, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207591-quick-way-to-spot-syntax-error/#findComment-1085378 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.