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
Post a Comment