moisesbr Posted August 15, 2013 Share Posted August 15, 2013 HI I have a code as below. But some times many "if"s can turn the program confuse, specialy if they are at the end of program.##################################If if today is sunday = "today is sunday if not suday show HTML code endif ############################## Is is possible to do as below to avoid endif at the end of very long program ? If if today is sunday= "today is sunday" Stop execution here. ## here I look for something as a return or cancel command used in other languagesendif show HTML code Link to comment https://forums.phpfreaks.com/topic/281196-avoiding-too-many-if-nesting/ Share on other sites More sharing options...
cyberRobot Posted August 15, 2013 Share Posted August 15, 2013 Perhaps exit() is what you're looking for: http://php.net/manual/en/function.exit.php Link to comment https://forums.phpfreaks.com/topic/281196-avoiding-too-many-if-nesting/#findComment-1445132 Share on other sites More sharing options...
clint Posted August 15, 2013 Share Posted August 15, 2013 You mean like: <?php if ($today =="Sunday") { echo 'today is sunday'; } ?> along those lines? Or as cyberRobot said ^^ Link to comment https://forums.phpfreaks.com/topic/281196-avoiding-too-many-if-nesting/#findComment-1445133 Share on other sites More sharing options...
moisesbr Posted August 15, 2013 Author Share Posted August 15, 2013 Hi clint Maybe I will achive it by inserting exit () as below. Not sure... <?phpif ($today =="Sunday") {echo 'today is sunday'; ### exit () } ?> ## execute HTML code here if it's not sunday. Link to comment https://forums.phpfreaks.com/topic/281196-avoiding-too-many-if-nesting/#findComment-1445139 Share on other sites More sharing options...
cyberRobot Posted August 15, 2013 Share Posted August 15, 2013 If all you want to do is display a message and prevent further code from being executed on Sundays, exit() is what you're looking for. If you're looking to accomplish something else, let us know. Link to comment https://forums.phpfreaks.com/topic/281196-avoiding-too-many-if-nesting/#findComment-1445144 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.