php - Why is this syntax valid? -


i've answered question today had simple solution, i've yet understand why php interpreter didn't throw syntax error. question simple:

why statements below considered have valid syntax?

someidentifier:; anythinggoesapparently:; thiscangoonandon:; 

even more since identifiers not defined anywhere.


to knowledge colon : used part of 2 operators: the scope resolution operator, the ternary operator, not on own. it's used in alternative syntax control structures. none of these qualify in case, bugging me crazy.

i believe these interpreted goto labels.

for example:

$x = 0; goto thisisbad; $x++;  thisisbad: $x += 2;  echo $x; 

output: 2

reference: http://php.net/manual/en/control-structures.goto.php


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -