Skip to main content

Control Structures_Loop In Php — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Control Structures_Loop In Php — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
39
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
47 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
39

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/39 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = 0 while ( $i < 3 ) { $i ++ ; } print $i; ?>

Question 2 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = 0 do { $i ++ ; } while ( $i < 3 ) ; print $i; ?>

Question 3 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = 0 while ( $i ++ ) { print $i; } print $i; ?>

Question 4 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = "" ; while ( $i ) { print "hi" ; } print "hello" ; ?>

Question 5 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = "" ; while ( $i ) { print "hi" ; } while ( $i < 8 ) $i ++ ; print "hello" ; ?>

Question 6 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = 0 ; while ( $i = 10 ) { print "hi" ; } print "hello" ; ?>

Question 7 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = "" ; while ( $i = 10 ) { print "hi" ; } print "hello" ; ?>

Question 8 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = 5 ; while (-- $i > 0 ) { $i ++ ; print $i; print "hello" ; } ?>

Question 9 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = 5 ; while (-- $i > 0 && ++ $i ) { print $i; } ?>

Question 10 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php span> $i = 0 ; while ( ? ++ $i || -- $i ) { print $i; } ?>

Question 11 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = 0 ; while (++ $i && -- $i ) { print $i; } ?>

Question 12 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = 0 ; while ((-- $i > ++ $i ) - 1 ) { print $i; } ?>

Question 13 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = 2 ; while (++ $i ) { while ( $i --> 0 ) print $i; } ?>

Question 14 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $i = 0 ; for ( $i ) { print $i; } ?>

Question 15 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $x = 0 ; $x <= 10 ; print ++ $x ) { print ++ $x; } ?>

Question 16 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $x =1 ; $x < 10 ; ++ $x) { print "*t" ; } ?>

Question 17 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $x = - 1 ; $x < 10 ; -- $x ) { print $x; } ?>

Question 18 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $x; for ( $x = - 3 ; $x < - 5 ; ++ $x ) { print ++ $x; } ?>

Question 19 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $ i++ ; $i == 1 ; $i = 2 ) print "In for loop " ; print "After loopn" ; ?>

Question 20 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( 1 ; $i == 1 ; $i = 2 ) print "In for loop " ; print "After loopn" ; ?>

Question 21 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <<php for ( $i == 2 ; ++ $i == $i; ++ $i ) print "In for loop " ; print "After loopn" ; ?>

Question 22 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $x = 1 ; $x < 10 ; $x ++) for ( $y = 1 ; $y < 5 ; $y ++) print "Hello" ; ?>

Question 23 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $count = 1 ; $count != 20 ;$count ++) { print $count; $count ++ ; } ?>

Question 24 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $count = 1 ; $count < 20 ; $count ++) ; print $count; ?>

Question 25 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $count = 0 ; $count < 3 ;$count ++) ; { print "hi" ; continue ; print "hello" ; } ?>

Question 26 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $count = 0 ; $count < 3 ;$count ++) ; { print "hi" ; break ; print "hello" ; } ?>

Question 27 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for (++ $i; ++ $i; ++ $i ) { print $i; if ( $i == 4 ) break ; } ?>

Question 28 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $i = 0 ;$i = - 1;$i = 1 ) { print $i; if ( $i != 1 ) break ; } ?>

Question 29 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( ;; ) { print "10" ; } ?>

Question 30 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $i = 0 ; - 5 ; $i ++) { print "i" ; if ( $i == 3 ) break ; } ?>

Question 31 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $i = 0 ; 0 ; $i ++) { print "i" ; } ?>

Question 32 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <php for ( $i = 0 ; $i < 5 ; $i ++) { for ( $j = $i; $j > 0 ; $ i--) print $i; } ?>

Question 33 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $i = 0 ; $i < 5 ; $i ++) { for ( $j = $i;$j > $i; $i --) print $i; } ?>

Question 34 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $user = array( "Ashley" , "Bale" , "Shrek" , "Blank" ) ; for ( $x = 0 ; $x < count( $user ) - 1 ; $x ++) { if ( $user [ $x ++] == "Shrek" ) continue ; printf ( $user [ $x ]) ; } ?>

Question 35 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $i = 0 ; $i % ++ $i; $i ++) { print "i" ; } ?>

Question 36 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php for ( $i = 0 ; $i < 5 ; $i ++) { for ( ; $i < 5 ; $i ++) print "i" ; } ?>

Question 37 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $a = array( "hi" , "hello" , "bye" ) ; foreach ( $a as $value ) { if (count( $a ) == 2 ) print $value; } ?>

Question 38 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $a = array( "hi" , "hello" , "bye" ) ; for (;count( $a ) < 5 ; ) { if (count( $a ) == 3 ) print $a; } ?>

Question 39 of 39
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php if (- 100 ) print "hi" ; else print "how are u" ; ?>

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →