Control Structures_Loop In Php — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Control Structures_Loop In Php — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress | 0/40 answered
✓ 0 correct
✗ 0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 0 ; if ($x ++ ) print "hi" ; else print "how are u" ; ?>
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x; if ($x == 0 ) print "hi" ; else print "how are u" ; print "hello" ?>
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 0 ; if ($x == 1 ) if ($x >= 0 ) print "true" ; else print "false" ; ?>
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 1 ; if ($a -- ) print "True" ; if ($a ++ ) print "False" ; ?>
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 1 ; if ( echo $a) print "True" ; else print "False" ; ?>
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 1 ; if ( print $a) print "True" ; else print "False" ; ?>
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 10 ; if ( 1 ) print "all" ; else print "some" else print "none" ; ?>
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 10 ; if ( 0 ) print "all" ; if else print "some" ?>
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = ""; if ( $a ) print "all" ; if else print "some"; ?>
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = "a" ; if ( $a ) print "all" ; else print "some" ; ?>
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 10 ; $y = 20 ; if ( $x > $y + $y != 3 ) print "hi" ; else print "how are u" ; ?>
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 10 ; $y = 20 ; if ( $x > $y && 1 || 1 ) print "hi" ; else print "how are u" ; ?>
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php if ( 0.1 ) print "hi" ; else print "how are u" ; ?>
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php if ( 0.0 ) print "hi" ; else print "how are u" ; ?>
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php if (print "0" ) print "hi" ; else print "how are u" ; ?>
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 1 ; if ( $x == 2 ) print "hi" ; else if ($x = 2 ) print $x; else print "how are u" ; ?>
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 1 ; if ( $x = $x & 0 ) print $x ; else print "how are u" ; ?>
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 1 ; if ($x = $x & 0 ) print $x; else break ; ?>
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 10 ; $y = 5 ; $z = 3 ; if ($x / $y / $z) print "hi" ; else print "hello" ; ?>
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php if ( !print "hi" ) if ( print "hello" ) print "hi" ; ?>
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php if ( print "hi" - 1 ) print "hello" ?>
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 1 ; if ($x -- ) print "hi" $x -- ; else print "hello" ?>
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 10 ; $b = 11 ; if ($a < ++ $a || $b < ++ $b) print "hello" ; else print "hi" ; ?>
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 2 ; if ($a -- - -- $a - $a) print "hello" ; else print "hi" ; ?>
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = "hello" ; if ($a . length) print $a . length; else print "hi" ; ?>
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = "hello" ; if ( strlen( $a ) ) print strlen ($a); else print "hi" ; ?>
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = "1" ; $b = "0" ; if ( ( int ) $a && $b) print "hi" ; else print "hello" ; ?>
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = "1" ; switch ( $a ) { case 1 : print "hi" ; case 2 : print "hello" ; default : print "hi1" ; } ?>
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = "2" ; switch ( $a ) { case 1 : print "hi" ; case 2 : print "hello" ; break ; default : print "hi1" ; } ?>
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = "1" ; switch ( $a ) { case 1 : break ; print "hi" ; case 2 : print "hello" ; break ; default : print "hi1" ; } ?>
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = "1" ; $a = 1 ; $b = 1 ; switch ( $a ) { case $a * $b : print "hi" ; break ; case $a / $b : print "hello" ; break ; default : print "hi1" ; } ?>
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 97 ; switch (? $a ) { case "a" : print "hi" ; break ; case 97 : print "hello" ; break ; default : print "hi1" ; } ?>
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $b = 1 ; switch ( $b ) { case 1.0 : print "hi" ; break ; case 1 : print "hello" ; break ; default : print "hi1" ; } ?>
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php const $b = 1 ; switch ( $b ) { case 1 : print "hi" ; break ; case 1 : print "hello" ; break ; default : print "hi1" ; } ?>
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $b = 1 ; switch (print $b ) { case 2 : print "hello" ; break ; case 1 : print "hi" ; break ; default : print "hi1" ; } ?>
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php switch ( $b ) { case 2 : print "hello" ; break ; case 1 : print "hi" ; break ; } ?>
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php switch ( $b ) { case 2 : print "hello" ; break ; case b : print "hi" ; break ; } ?>
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php while () { print "hi" ; } ?>
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php do { print "hi" ; } while ( 0 ) ; print "hello" ; ?>
✓ Link copied to clipboard
Continue Your Practice
Next Practice Set → Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡 Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.