0

Whats wrong with my code ?

<?php $life= "you"; if ($life=="you");{ echo"you're my life "; break; } elseif ($life !="you");{ echo "you're not my life"; break; } else echo " its either you're my life or not"; ?>

16th Jul 2017, 6:08 PM
Patrick Estaron Magayon
Patrick Estaron Magayon - avatar
8 Réponses
+ 8
The code is kinda weird, but still.. -_- Don't use break inside if-else. There will be no semicolon after the conditions <?php $life= "you"; if ($life=="you"){ echo"you're my life "; } elseif ($life !="you"){ echo "you're not my life"; } else echo " its either you're my life or not"; ?>
16th Jul 2017, 6:13 PM
Shamima Yasmin
Shamima Yasmin - avatar
0
haha noted advised thanks :)
16th Jul 2017, 6:14 PM
Patrick Estaron Magayon
Patrick Estaron Magayon - avatar
- 1
what warning are you getting?
16th Jul 2017, 6:10 PM
Dillion Piazza
Dillion  Piazza - avatar
- 1
Parse error: syntax error, unexpected 'elseif' (T_ELSEIF), expecting end of file in ..\Playground\ PHP Parse error: syntax error, unexpected 'elseif' (T_ELSEIF), expecting end of file in ..\Playground\
16th Jul 2017, 6:11 PM
Patrick Estaron Magayon
Patrick Estaron Magayon - avatar
- 1
try "else if" not "elseif"
16th Jul 2017, 6:11 PM
Dillion Piazza
Dillion  Piazza - avatar
- 1
noted , gonna try it thanks
16th Jul 2017, 6:12 PM
Patrick Estaron Magayon
Patrick Estaron Magayon - avatar
- 1
I'm not familiar with php i just took a quick glimpse to see a typo so sorry if my answer isn't correct
16th Jul 2017, 6:13 PM
Dillion Piazza
Dillion  Piazza - avatar
- 1
why not try if, if, else? thats if it has any similarities to java.
16th Jul 2017, 9:40 PM
D_Stark
D_Stark - avatar