+ 6

Why does it say unexpected else placement?

<?php function returnTrue($str){ if ($str == "");{ echo "True"; } else { echo "False"; } return ("") } ?>

29th Jan 2020, 7:22 PM
MyNameIsMutable
MyNameIsMutable - avatar
4 Réponses
+ 15
MyNameIsMutable first error mention by taste about semicolon after if statement which blocking if block so error is coming unnecessary placement of else statement so remove that semicolon Second error return statement after that semicolon is missing so put that. Third calling of function with argument is missing add function call. <?php function returnTrue($str){ if ($str == ""){ echo "True"; } else { echo "False"; } return (""); } returnTrue(""); ?>
29th Jan 2020, 7:29 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 6
you already close if statement with semicolon ( ; )
29th Jan 2020, 7:24 PM
Taste
Taste - avatar
+ 3
Remove semicolon on 3rd line and move it to after the return("")
29th Jan 2020, 8:51 PM
Sonic
Sonic - avatar
0
Helped out allot
29th Jan 2020, 7:45 PM
MyNameIsMutable
MyNameIsMutable - avatar