Kryllster Posted May 27, 2009 Share Posted May 27, 2009 I have some code / code blocks concerning case block and have basically 2 questions. First which of these is the correct way to write a case block or which is the best. 1. case main; include('somefile.php'); break; 2 case: 'main'; include('somefile.php'); break; 3. case "main"; include("somefile.php"); break; which leads to the next question when do you use double quotes and when do you use single quotes? If it really doesnt matter. then I guess it should be pretty uniform across documents etc.. Link to comment https://forums.phpfreaks.com/topic/159806-which-way-is-the-best/ Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 I say none of them. case 'main': include('somefile.php'); break; See the colon instead of the semi-colon? If you use a semi-colon, your include statement will always run regardless. There isn't a general rule on when to use double quotes or single quotes. If you must use variable interpolation, then double quotes. I tend to start with single quotes and use double quotes for HTML attributes. But speed difference, almost the same. Link to comment https://forums.phpfreaks.com/topic/159806-which-way-is-the-best/#findComment-842892 Share on other sites More sharing options...
corbin Posted May 27, 2009 Share Posted May 27, 2009 If we want to get really technical, include is a language construct, not a function, therefore () is not necessary and if I remember correctly, it should not be used. Link to comment https://forums.phpfreaks.com/topic/159806-which-way-is-the-best/#findComment-842898 Share on other sites More sharing options...
cunoodle2 Posted May 27, 2009 Share Posted May 27, 2009 If we want to get really technical, include is a language construct, not a function, therefore () is not necessary and if I remember correctly, it should not be used. Corbin I just wanted to say... "Hi, hey and whad up world." Do you get that much? Link to comment https://forums.phpfreaks.com/topic/159806-which-way-is-the-best/#findComment-842908 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.