Operators And Expressions In Php — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Operators And Expressions In Php — Part 2 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 $four4 = 4 ; $three3 = 3 ; $two2 = 2 ; echo $four4 + $three3 / $two2 - 1 ; ?>
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $4four = 4 ; $3three = 3 ; $2two = 2 ; echo $4four + $3three / $2two - 1 ; ?>
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php int $one = 1 ; echo "$one" ; ?>
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php var $one = 1 ; var $two = 2 ; echo $one / $two * $one / $two * $two; ?>
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $hello = "Hello World" ; $bye = "Bye" ; echo $hello; "$bye" ; ?>
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x; echo "$x" ; ?>
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 5 ; { $x = 10 ; echo "$x" ; } echo "$x" ; ?>
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 5 ; function fun () { echo "$x" ; } fun () ; ?>
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 5 ; function fun () { $x = 10 ; echo "$x" ; } fun () ; echo "$x" ; ?>
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 4 ; $y = 3 ; function fun ( $x = 3 , $y = 4 ) { $z = $x + $y / $y + $x; echo "$z" ; } echo $x; echo $y; echo $z; fun ( $x, $y ) ; ?>
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 4 ; $y = 3 ; function fun ( $x, $y ) { $z = $x + $y / $y + $x; echo "$z" ; } echo $x; echo $y; echo $z; fun ( 3 , 4 ) ; ?>
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php function fun ( $x,$y ) { $x = 4 ; $y = 3 ; $z = $x + $y / $y + $x; echo "$z" ; } fun ( 3 , 4 ) ; ?>
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 3 , 4 , 5 , 6 ; echo "$x" ; ?>
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 10 ; $b = 4 ; $c = fun ( 10 , 4 ) ; function fun ( $a,$b ) { $b = 3 ; return $a - $b + $b - $a; } echo $a; echo $b; echo $c; ?>
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = "$winner" ; $b = "/$looser" ; echo $a,$b; ?>
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 5 ; $y = 10 ; function fun () { $GLOBALS[ 'y' ] = $GLOBALS[ 'x' ] + $GLOBALS[ 'y' ] ; } fun () ; echo $y; ?>
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 5 ; $y = 10 ; function fun () { $y = $GLOBALS[ 'x' ] + $GLOBALS[ 'y' ] ; } fun () ; echo $y; ?>
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php function fun () { $x = 0 ; echo $x; $x ++ ; } fun () ; fun () ; fun () ; ?>
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php function fun () { static $x = 0 ; echo $x; $x ++ ; } fun () ; fun () ; fun () ; ?>
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php static $x = 0 ; function fun () { echo $x; $x ++ ; } fun () ; fun () ; fun () ; ?>
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 0 ; function fun () { echo $GLOBALS[ 'x' ] ; $GLOBALS[ 'x' ]++ ; } fun () ; fun () ; fun () ; ?>
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 0 ; function fun () { echo $GLOBALS[ 'x' ] ; $x ++ ; } fun () ; fun () ; fun () ; ?>
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 10 ; echo ++ $a; echo $a ++ ; echo $a; echo ++ $a; ?>
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 12 ; -- $a; echo $a ++ ; ?>
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = "test" ; $y = "this" ; $z = "also" ; $x .= $y .= $z ; echo $x; echo $y; ?>
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $x = 1 ; $y = 2 ; if (++ $x == $y ++) { echo "true " , $y, $x; } ?>
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $y = 2 ; $w = 4 ; $y *= $w /= $y; echo $y, $w; ?>
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $y = 2 ; if ( $y -- == ++ $y ) { echo $y; } ?>
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $y = 2 ; if (** $y == 4 ) { echo $y; } ?>
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $y = 2 ; if (-- $y == 2 || $y xor -- $y ) { echo $y; } ?>
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $y = 2 ; if (-- $y <> ($y != $y ++)) { echo $y; } ?>
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php echo $x -- != ++ $x; ?>
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $auth = 1 ; $status = 1 ; if ( $result = (( $auth == 1 ) && ( $status != 0 ))) { print "result is $result" ; } ?>
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php echo 5 * 9 / 3 + 9 ; ?>
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $i = 0 ; $j = 0 ; if ( $i && ( $j = $i + 10 )) { echo "true" ; } echo $j; ?>
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $i = 10 ; $j = 0 ; if ( $i || ( $j = $i + 10 )) { echo "true" ; } echo $j; ?>
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $i = 1 ; if ( $i ++ && ( $i == 1 )) printf( "Yesn$i" ) ; else printf( "Non$i" ) ; ?>
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 1 ; $b = 3 ; $d = $a ++ + ++ $b; echo $d; ?>
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following PHP code ? <?php $a = 1 ; $b = 1 ; $d = 1 ; print ++ $a + ++ $a + $a ++ ; print $a ++ + ++ $b; print ++ $d + $d ++ + $a ++ ; ?>
✓ 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.