PHP Programming : if...else, if...var, switch, for, while and Do while, break and continue

in #esteem7 years ago (edited)

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:
$hari";?>
  • Program if...special
    EX:
$tahun $kabisat";?>
  • 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

[CODEPOLITAN]


Don't forget upvote and follow me @muadzis and see you next time

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.033
BTC 94693.28
ETH 3119.47
USDT 1.00
SBD 3.05