0
Q:

php if elseif g

<?php
if ($a > $b) {
    echo "a is bigger than b";
} elseif ($a == $b) {
    echo "a is equal to b";
} else {
    echo "a is smaller than b";
}
?>
5
$a = random_int(0, 10);
$b = random_int(0, 10);
if ($a > $b) {
  echo 'a is greater than b';
} elseif ($a == $b) {
  echo 'a is equal to b';
} else {
  echo 'a is less than b';
}
8

if (condition) {

    code to be executed if this condition is true;

 }
elseif (condition) {

    code to be executed if first condition is false and this 
  condition is true;

 } else {

  code to be executed if all conditions are false;

}
1

<?php

$t = date("H");


if ($t < "20") {

 
echo "Have a good day!";

 }
else {

  echo 
"Have a good night!";

 }

?>
 
1

<?php

$t = date("H");

 
if ($t < "10") {

  echo "Have a good morning!";

 }
elseif ($t < "20") {

    echo "Have a good day!";

 } else {

  echo "Have a good night!";

 }

?>
 
1
if ($t < "20") {
    echo "Have a good day!";
} 
else if($t < "40" {
    echo "Have a good afternoon!";
}
else{
 	echo "Have a good evening!"; 
}
3

if (condition) {

    code to be executed if condition is true;

 }
else {

  code to be executed if condition is false;

 }
0

New to Communities?

Join the community