serverman Posted May 23, 2008 Share Posted May 23, 2008 would it have been better to use case over if in this snippet of my script. <?php// Below checks to see if anything was forgotten!!!! // if ($q1 == "") { die ("You forgot something, go back and check over your quiz."); } if ($q2 == "") { die ("You forgot something, go back and check over your quiz."); } if ($q3 == "") { die ("You forgot something, go back and check over your quiz."); } if ($q4 == "") { die ("You forgot something, go back and check over your quiz."); } if ($q5 == "") { die ("You forgot something, go back and check over your quiz."); }if ($q6 == "") { die ("You forgot something, go back and check over your quiz."); } if ($q7 == "") { die ("You forgot something, go back and check over your quiz."); } if ($q8 == "") { die ("You forgot something, go back and check over your quiz."); } if ($q9 == "") { die ("You forgot something, go back and check over your quiz."); } if ($q10 == "") { die ("You forgot something, go back and check over your quiz."); } // Below is where the answers are checked actually displayed //?> Link to comment https://forums.phpfreaks.com/topic/106987-solved-quick-question/ Share on other sites More sharing options...
rhodesa Posted May 23, 2008 Share Posted May 23, 2008 If it's the same die statement, just use 1 if: <?php// Below checks to see if anything was forgotten!!!! // if (empty($q1) || empty($q2) || empty($q3) || empty($q4) || empty($q5) || empty($q6) || empty($q7) || empty($q8) || empty($q9) || empty($q10)) { die ("You forgot something, go back and check over your quiz."); } // Below is where the answers are checked actually displayed //?> Link to comment https://forums.phpfreaks.com/topic/106987-solved-quick-question/#findComment-548378 Share on other sites More sharing options...
serverman Posted May 23, 2008 Author Share Posted May 23, 2008 Thanks that made it run 2 times faster . Link to comment https://forums.phpfreaks.com/topic/106987-solved-quick-question/#findComment-548385 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.