A simple PHP if
/ else
condition looks like this:
if(true) {
echo("Hello World!");
} else {
echo("Goodbye World!");
}
The "alternative syntax" looks like this:
if(true):
echo("Hello World!");
else:
echo("Goodbye World!");
endif;
I have a few questions regarding this "alternative syntax":
- When / in what case should I use it?
- Where / in which part of my script should I use it?
- Why should I use it / what purpose does it serve & are there any benefits to using it?
- Why was it created, does the "alternative syntax" have features that "original syntax" doesn't?
Thank you for you time & help in advance.
endif;
orendforeach;
then}
or}
. Basically it makes it a bit more readable when in the html. That said, like 99% of the time I use a template system and MVC structure. – Wrack