PHP if-else statement CODE
The code will output "Have a nice weekend!" if the current day is Friday, otherwise - "Have a nice day!"
$d = date("D");
if($d == "Fri"){
    echo "Have a nice weekend!";
} else{
    echo "Have a nice day!";
}
echo "\n";
Output "Have a good day!" if the current time is less than 20, and "Have a good night!" otherwise:
$t = date("H");
if ($t < "20") {
    echo "Have a good day!";
} else {
    echo "Have a good night!";
}
If
$age
is more than
18
, prints
Adult
otherwise prints
Child
$age = 20;
if ($age > 18) {
    echo 'Adult';	
} else {
    echo 'Child';	
}
by Valeri Tandilashvili
2 years ago
PHP
If / else
2
Pro tip: use ```triple backticks around text``` to write in code fences