IF and ELSE without brackets not working in PHP | |||||||||||
When I use IF and ELSE without brackets in PHP, it seem to be not working properly. Is there a difference between the functions with and without brackets ? | |||||||||||
| |||||||||||
Hi, The difference is when you use IF and ELSE without brackets, it will work only with one statement after IF. For example this will work: IF ( $a == $b ) echo "OK"; ELSE echo "NOK"; But this will not work: IF ( $a == $b ) echo "OK"; $value = 1 ; ELSE echo "NOK"; I recommend to use IF and ELSE with brackets, when creating conditions. | |||||||||||
| |||||||||||
| |||||||||||
![]() ![]() ![]() ![]() | |||||||||||
2022 AnswerTabs | Terms | Contact us |