galvin Posted February 11, 2011 Share Posted February 11, 2011 Just curious, what is proper programming in cases where you're just doing a simple IF statement where there really is no need for an ELSE. Should you still write out the ELSE? For example, which is proper... if (x=1) { //code here to do something } or if (x=1) { //code here to do something } else { } There would be nothing in the ELSE statement, so is it OK to just leave it out completely (i.e. version #1), or is it proper to still have it listed (i.e. version #2)? Link to comment https://forums.phpfreaks.com/topic/227321-proper-syntax-with-if-statements-that-have-no-else/ Share on other sites More sharing options...
btherl Posted February 11, 2011 Share Posted February 11, 2011 #1 is fine. Link to comment https://forums.phpfreaks.com/topic/227321-proper-syntax-with-if-statements-that-have-no-else/#findComment-1172550 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.