PHP else-if statement CODE
The code will output "Have a nice weekend!" if the current day is Friday, and "Have a nice Sunday!" if the current day is Sunday, otherwise it will output "Have a nice day!"
$d = date("D");
if($d == "Fri"){
    echo "Have a nice weekend!";
} elseif($d == "Sun"){
    echo "Have a nice Sunday!";
} else{
    echo "Have a nice day!";
}
echo "\n";
Outputs
Have a good morning!
if the current time is less than 10, and
Have a good day!
if the current time is less than 20. Otherwise it will output
Have a good night!
$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!";
}
Prints
Adult
If
$age
is more than
18
, and
Teenager
if the variable is less than 12. Otherwise it prints
Child
$age = 20;
if ($age > 18) {
    echo 'Adult';
} else if ($age > 12) {
    echo 'Teenager';
} else {
    echo 'Child';
}
by Valeri Tandilashvili
2 years ago
PHP
4
Pro tip: use ```triple backticks around text``` to write in code fences