Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- if (condition)
- {
- code to be executed if condition is true;
- }
- */
- $a = 9;
- $b = 7;
- if ( $a > $b ){
- echo 'A is bigger than B';
- }
- if ( $a < $b ){
- echo 'A is smaller than B';
- }
- if ( $a == $b ){
- echo 'A is equal to B';
- }
- echo '<br><hr>';
- /*
- if (condition)
- {
- code to be executed if condition is true;
- }
- else
- {
- code to be executed if condition is false;
- }
- */
- if ( $a > $b ){
- echo ' A is bigger than B';
- } else {
- echo 'A is smaller than B';
- }
- echo '<br><hr>';
- /*
- if (condition)
- {
- code to be executed if condition is true;
- }
- else if (condition)
- {
- code to be executed if condition is true;
- }
- else
- {
- code to be executed if condition is false;
- }
- */
- if ( $a == $b ){
- echo 'A is equal to B';
- }elseif ( $a < $b ) {
- echo 'A is smaller than B';
- } else {
- echo 'A is bigger than B';
- }
- echo '<br><hr>';
- /*
- switch (n)
- {
- case label1:
- code to be executed if n=label1;
- break;
- case label2:
- code to be executed if n=label2;
- break;
- default:
- code to be executed if n is different from both label1 and label2;
- }
- */
- $favcolor = 'pink';
- switch ($favcolor) {
- case "red":
- echo 'Your favourate color is red';
- break;
- case "green":
- echo 'Your favourate color is green';
- break;
- default:
- echo 'None of this is your favourate color';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement