Syntax Error

A syntax error is an error in the source code of a program. Since computer programs must follow strict syntax to compile correctly, any aspects of the code that do not conform to the syntax of the programming language will produce a syntax error.

Unlike logic errors, which are errors in the flow or logic of a program, syntax errors are small grammatical mistakes, sometimes limited to a single character. For example, a missing semicolon at the end of a line or an extra bracket at the end of a function may produce a syntax error. In the PHP code below, the second closed bracket would result in a syntax error since there is only one open bracket in the function.

function testFunction()
{
echo "Just testing.";
}}

Some software development IDEs check the source code for syntax errors in real-time, while others only generate syntax errors when a program is compiled. Even if a source code file contains one small syntax error, it will prevent an application from being successfully compiled. Similarly, if you run a script through an interpreter, any syntax errors will prevent the script from completing. In most cases, the compiler or interpreter provides the location (or line number) of the syntax error, making it easy for the programmer to find and fix the error.

Updated April 27, 2012 by Per C.

quizTest Your Knowledge

Guidelines that serve as the building blocks of an algorithm are also called what?

A
Mnemonics
0%
B
Heuristics
0%
C
Abstractions
0%
D
Samples
0%
Correct! Incorrect!     View the Heuristic definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of Syntax Error on this page is an original definition written by the TechTerms.com team. If you would like to reference this page or cite this definition, please use the green citation links above.

The goal of TechTerms.com is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about this definition or would like to suggest a new technical term, please contact us.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.