I was practising statements and ran into a problem. I’m trying to make it so that if $child3 is available, then it will echo all three children, like how when $child2 is available, it echos Kim & Pom. What did I do wrong?
$child = "Kim";
$child2 = "Pom";
$child3 = "Rob";
if($child2) {
echo $child; echo " "; echo $child2;
} elseif($child3) {
echo $child; echo " "; echo $child2; echo " "; echo $child3;
} else {
echo $child;
}
Try reversing the conditions:
You might also like the wonderful string concatenation operator
..