PHP Programming : if...else, if...var, switch, for, while and Do while, break and continue
Hi steemian...
On this occasion I will share again with you guys about PHP programming.
- Program if...else2
The if....else statement executes some code if a condition is true and another code if that condition is false.
EX:
- Program if...var
Variable is a memory we can name and then we use to store one value and read it later. Variable is a very useful element in programming including in PHP in making an application.
EX:
- Program switch
The Switch command is used to check the truth of a value by having multiple selections or checking values.
EX:
- Program if...special
EX:
- Program for
"; /* contoh 2 */ for ($i = 1; ; $i++) { if ($i > 10) { break; } echo "$i "; } echo "
"; /* contoh 3 */ $i = 1; for (; ; ) { if ($i > 10) { break; } echo "$i "; $i++; } echo "
"; /* contoh 4 */ for ($i = 1; $i
- Program while
while is the simplest form of looping in PHP, this loop is used when the number of loops we do not know or when we do not want to write the number of iteration (on expression).
EX:
"; /* contoh 2 */ $i = 1; while ($i
"; /* contoh 3 */ $i = 1; while ($i Heading $i"; $i++; }?>
- Program do while
Do while is also used when we do not know the end of the loop, but the difference expression is checked after the loop / statement occurs, so there is at least one execution statement.
- Program break and continue
Continue and break deserve much more credit. Continue and break provide extra control over your loops by manipulating the flow of the iterations. Continue is the nicer one of the two as it prevents the current iteration, or flow through one pass of the loop, and just tells PHP to go to the next round of the loop. Break provides more aggressive control by completing skipping out of the loop and onto the code following the loop. If you have ever played the card game UNO, continue is basically the skip card, and break is someone slamming their cards down screaming I am the winner and leaves the room. Let’s go through some examples to see how to use them.
EX:
Maybe enough so for my discussion this time about PHP Programming maybe I will continue on the other occasion.
Source
Source
Plagiarism is the copying & pasting of others work without giving credit to the original author or artist. Plagiarized posts are considered spam.
Spam is discouraged by the community, and may result in action from the cheetah bot.
More information and tips on sharing content.
If you believe this comment is in error, please contact us in #disputes on Discord