I am writing a script to make chunks of a text and send it via SMS. Earlier today i was reviewing some code to split the string in chunks and i saw something I\'ve never see
In some cases you need to have a semicolon after a closing curly bracket!
Example:
if(1==1):
if(true){ echo "it's true"; } //no semicolon here => syntax error!
else:
echo "no never ever";
endif;
Of course you would't use alternative syntax for control structures if there is only php code.
But if you have a mix of HTML and PHP code you could use the alternative syntax for control structures (alternate syntax makes the code only clearer and easyer to read), but the problem then is that in some cases a plugin or for example a tag parser of a cms could produce an if statement with curly brackets (without a "closing semicolon") just before the "else:" and this would lead to a syntax error in the resulting php file.
The above code would work like this:
if(1==1):
if(true){ echo "it's true"; };
else:
echo "no never ever";
endif;