Alternate Control Syntaxes

Author Topic: Alternate Control Syntaxes  (Read 1554 times)

Offline chinmay.sahooTopic starter

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 2
  • Posts: 158
  • Karma: 0
    • We Helpline
Alternate Control Syntaxes
« on: 12-15-2015, 04:15:06 »
PHP offers another way to start and end the bodies of the if, switch, for, and while constructs. It amounts to replacing the initial brace of the enclosed block with a colon and the closing brace with a special ending statement for that construct (endif, endswitch, endfor, and endwhile). For example, the if syntax becomes

Quote
if (expression):
statement1
statement2
..
endif;

Or:

Quote
if (expression):
statement1
statement2
..
elseif (expression2):
statement3
..
else:
statement4
..
endif;


Offline harrywood

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 2
  • Posts: 163
  • Karma: 1
    • Mobile & web apps development
Re: Alternate Control Syntaxes
« Reply #1 on: 03-02-2019, 00:04:08 »
PHP offers an alternative syntax for some of its control structures; namely, if, while, for, foreach, and switch. In each case, the basic form of the alternate syntax is to change the opening brace to a colon (:) and the closing brace to endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively.

 

Related Topics

  Subject / Started by Replies Last post
0 Replies
1792 Views
Last post 11-24-2010, 12:36:03
by thosecars82
5 Replies
2818 Views
Last post 03-03-2019, 03:44:50
by Rattan11
1 Replies
1979 Views
Last post 03-02-2019, 00:05:38
by harrywood
2 Replies
1792 Views
Last post 11-14-2012, 08:09:49
by dave-o99
0 Replies
1959 Views
Last post 01-30-2017, 03:09:44
by beingchinmay