2

As I check through Magento, they tend not to use starting and ending curly brackets (braces) in the code. For example generally we use { and } brackets in the code but in Magento, they are using : or endif.

Can you please let me know why they don't use curly brackets and what is the use of : and endif ?

Thanks in advance

Fiasco Labs
  • 6,457
  • 3
  • 32
  • 43
Vipul Jethva
  • 647
  • 1
  • 7
  • 27

2 Answers2

1

You should read this:

Difference between if () { } and if () : endif;

Is part of the coding standard but there isn't really a very clear advantage to it.

Community
  • 1
  • 1
1

Generally, in Magento, if() statements (et.al.) will use curly brackets to surround code blocks in module code programming and libraries (files ending in .php) and will use the alternate syntax <?php if(): > <?php endif; > in .phtml files where you find PHP code interspersed with html code.

It's mostly a coding decision to separate html and php code for readability when you are writing templates.

Fiasco Labs
  • 6,457
  • 3
  • 32
  • 43