revision:
code: <?php $a = 10; $b = 5; echo ($a + $b) . "< br>"; echo ($a - $b) . "< br>"; echo ($a * $b) . "< br>"; echo ($a / $b) . "< br>"; echo ($a % $b) . "< br>"; echo ($a ** $b) . " < br>"; echo "< br>"; $c = 20; echo $c . "< br>"; $c = 20; $c /= 100; echo $c . "< br>"; $c = 20; $c %= 13; echo $c . "< br>"; echo "< br>"; $d = 100; $e = "100"; var_dump($d == $e); echo "< br>"; $d = 100; $e = "100"; var_dump($d === $e); echo "< br>"; $d = 100; $e = "100"; var_dump($d != $e); echo "< br>"; $d = 100; $e = "100"; var_dump($d <> $e); echo "< br>"; $d = 100; $e = "100"; var_dump($d !== $e); echo"< br>"; $d = 100; $e = "100"; var_dump($d > $e); echo"< br>"; $d = 100; $e = "100"; var_dump($d < $e); echo"< br>"; $d = 100; $e = "100"; var_dump($d >= $e); echo"< br>"; $d = 100; $e = "100"; var_dump($d <= $e); echo"< br>"; $d = 100; $e = "100"; var_dump($d <=> $e); echo"< br>"; echo "< br>"; $f = 10; echo ++$f; echo "< br>"; $f = 10; echo $f++; echo "< br>"; $f = 10; echo --$f; echo "< br>"; $f = 10; echo $f--; echo "< br>"; echo "< br>"; $g = 100; $h = 50; if ($g == 100 and $h == 50) { echo "Hello world!"; } echo "< br>"; if ($g == 100 or $h == 80) { echo "Hello world!"; } echo "< br>"; if ($g == 100 xor $h == 80) { echo "Hello world!"; } echo "< br>"; if ($g == 100 && $h == 50) { echo "Hello world!"; } echo "< br>"; if ($g == 120 || $h == 50) { echo "Hello world!"; } echo "< br>"; if ($g !== 110 ) { echo "Hello world!"; } echo "< br>"; echo "< br>"; $txt1 = "Hello"; $txt2 = " world!"; echo $txt1 . $txt2; echo "< br>"; $txt1 = "Hello"; $txt2 = " world!"; $txt1 .= $txt2; echo $txt1; echo "< br>"; echo "< br>"; $j = array("a" => "red", "b" => "green"); $k = array("c" => "blue", "d" => "yellow"); print_r($j + $k); echo "< br>"; var_dump($j == $k); echo "< br>"; var_dump($j === $k); echo "< br>"; var_dump($j != $k); echo "< br>"; var_dump($j <> $k); echo "< br>"; var_dump($j !== $k); echo " < br>"; echo "< br>"; // if empty($user) = TRUE, set $status = "anonymous" echo $status = (empty($user)) ? "anonymous" : "logged in"; echo("< br>"); $user = "Edgard Peeters"; // if empty($user) = FALSE, set $status = "logged in" echo $status = (empty($user)) ? "anonymous" : "logged in"; echo("< br>"); echo("< br>"); // variable $user is the value of $_GET['user'] and 'anonymous' if it does not exist echo $user = $_GET["user"] ?? "anonymous"; echo("< br>"); // variable $color is "red" if $color does not exist or is null echo $color = $color ?? "red"; ? >
code: <?php $l = date("H"); if ($l < "20") { echo "Have a good day!";} print "< br>"; $m = date("H"); if ($m < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; } print "< br>"; $n = date("H"); echo "< a>The hour (of the server) is " . $n; echo ", and will give the following message:< /a>" . "< br>"; if ($n < "10") { echo "Have a good morning!"; } elseif ($n < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; } ? >
code: <?php $favcolor = "red"; switch ($favcolor) { case "red": echo "Your favorite color is red!"; break; case "blue": echo "Your favorite color is blue!"; break; case "green": echo "Your favorite color is green!"; break; default: echo "Your favorite color is neither red, blue, nor green!"; } ?>
code: <?php $x = 1; while($x <= 5) { echo "The number is: $x < br>"; $x++; } echo("< br>"); $x = 0; while($x <= 100) { echo "The number is: $x < br>"; $x+=20; } echo("< br>"); $x = 1; do { echo "The number is: $x < br>"; $x++; } while ($x <= 7); echo("< br>"); $x = 6; do { echo "The number is: $x < br>"; $x++; } while ($x <= 5); echo("< br>"); for ($x = 0; $x <= 10; $x++) { echo "The number is: $x < br>"; } echo("< br>"); for ($x = 0; $x <= 100; $x+=20) { echo "The number is: $x < br>"; } echo("< br>"); $colors = array("red", "green", "blue", "yellow"); foreach ($colors as $value) { echo "$value < br>"; } echo("< br>"); $age = array("Peter"=>"35", "Alice"=>"37", "Staf"=>"43"); foreach($age as $x => $val) { echo "$x = $val< br>"; } echo("< br>"); for ($x = 0; $x < 10; $x++) { if ($x == 4) { break; } echo "The number is: $x < br>"; } echo("< br>"); for ($x = 0; $x < 10; $x++) { if ($x == 4) { continue; } echo "The number is: $x < br>"; } ?>