Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consecutive semicolons ; not returning a syntax error?

Tags:

php

$name = 'John Doe';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$age = 16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$address = 'Planet Earth';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Should this be considered a bug? PHP does not return any syntax errors at all.

like image 671
Jürgen Paul Avatar asked Jan 23 '13 11:01

Jürgen Paul


People also ask

Is forgetting a semicolon a syntax error?

Omitting the semicolon at the end of a statement is a syntax error. The computer issues an error message when it cannot recognize the statement. These messages can occur at the point of the error, or after it.

Is a missing semicolon a syntax error in Java?

Compile Time Errors are those errors which prevent the code from running because of an incorrect syntax such as a missing semicolon at the end of a statement or a missing bracket, class not found, etc.

What is semicolon error?

A semicolon is used to connect two independent clauses. In this case, the phrase that follows the semicolon is not an independent clause (a complete sentence that can stand on its own), so the use of a semicolon here is incorrect. Changing the semicolon to a comma would correct the sentence's error.

How do you use a semicolon in a for loop?

Since the for loop executes a single operation (which could be a block enclosed in {} ) semicolon is treated as the body of the loop, resulting in the behavior that you observed. is interpreted as follows: Repeat five times for (i=0;i<5;i++) ... do nothing (semicolon)


2 Answers

It's not an error. It's just a statement with nothing in it. Perfectly valid.

like image 149
AgentConundrum Avatar answered Sep 22 '22 21:09

AgentConundrum


This is valid - It's just an empty statement

like image 45
ajtrichards Avatar answered Sep 21 '22 21:09

ajtrichards