Skip to main content

Operators And Expressions In Php — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Operators And Expressions 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
Question 1 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php "Hello World" ?>

Question 2 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php print_r "Hello world" ?>

Question 3 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $color = "red" ; echo "$color" ; echo "$COLOR" ; echo "$Color" ; ?>

Question 4 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php # echo "Hello world" ; echo "# Hello world" ; ?>

Question 5 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php echo "Hello World" ?>

Question 6 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php echo "echo "Hello World"" ; ?>

Question 7 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php <?php echo "Hello world" ; ?> ?>

Question 8 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $color = red; echo "$color" ; ?>

Question 9 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $color = red; echo "$color" . red ; ?>

Question 10 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $color1 = red; $color2 = green; echo "$color1" . "$color2" ; ?>

Question 11 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $color = "red" ; $color = "green" ; echo "$color" ; ?>

Question 12 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $color1 = "red" ; $color2 = "red" ; echo "$color1" + "$color2" ; ?>

Question 13 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $color1 = "red" ; $color2 = "1" ; echo "$color1" + "$color2" ; ?>

Question 14 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $color1 = "1" ; $color2 = "1" ; echo "$color1" + "$color2" ; ?>

Question 15 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $color1 = "red" ; $color2 = "1" ; $color3 = "grey" echo "$color1" + "$color2" . "$color3" ; ?>

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php echo "This" , "was" , "a" , "bad" , "idea" ; ?>

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $one = "Hello" ; $two = "World" ; echo $one, $two; ?>

Question 18 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $cars = array( "Volvo" , "BMW" , "Toyota" ) ; echo "My car is a {$cars[0]}" ; ?>

Question 19 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php print "echo hello world" ; ?>

Question 20 of 40
★ FPSC ★ PPSC

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

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $cars = array( "Volvo" , "BMW" , "Toyota" ); print $cars [ 2 ] ; ?>

Question 22 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $one = "one" ; $two = "two" ; print( $one$two ) ; ?>

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $one = "one" ; $two = "one" ; print( $one == $two ) ; ?>

Question 24 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php print( "this" . "was" . "a" . "bad" . "idea" ) ; ?>

Question 25 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php define( "GREETING", "PHP is a scripting language" ) ; echo $GREETING; ?>

Question 26 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php class Constants { define( 'MIN_VALUE' , '0.0' ) ; define( 'MAX_VALUE' , '1.0' ) ; public static function getMinValue () { return self :: MIN_VALUE; } public static function getMaxValue () { return self :: MAX_VALUE; } } echo Constants :: getMinValue () ; echo Constants :: getMaxValue () ; ?>

Question 27 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php define( "__LINE__" , "PHP is a scripting language" ) ; echo __LINE__; ?>

Question 28 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php define( 'IF' , 42 ) ; echo "IF: " , IF; ?>

Question 29 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php define( "NEW_GOOD_NAME_CONSTANT" , "I have a value" ) ; define( "OLD_BAD_NAME_CONSTANT" , NEW_GOOD_NAME_CONSTANT ) ; echo NEW_GOOD_NAME_CONSTANT; echo OLD_BAD_NAME_CONSTANT; ?>

Question 30 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php define( "VAR_NAME" , "test" ) ; ${VAR_NAME} = "value" ; echo VAR_NAME; ech o $ { VAR_NAME } ; ?>

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php class myObject { } define( 'myObject::CONSTANT' , 'test' ) ; echo myObject :: CONSTANT; ?>

Question 32 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $x = 5 ; $y = 10 ; $z = "$x + $y" ; echo "$z" ; ?>

Question 33 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $x = 4 ; $y = 3 ; $z = 1 ; echo "$x = $x + $y + $z" ; ?>

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $x = 4 ; $y = 3 $z = 1 ; $z = $z + $x + $y; echo "$z" ; ?>

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $x = 3.3 ; $y = 2 ; echo $x % $y; ?>

Question 36 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $x = 10 ; $y = 4 ; $z = 3 ; echo $x % $y % $z; ?>

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $x = 30 ; $y = 20 ; $z = 10 ; echo $x + $y - $z / ( $z - $y ) ; ?>

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $x = 4 ; $y = - 3 ; $z = 11 ; echo 4 + $y * $z / $x; ?>

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $x = 3.5 ; $y = 2 ; $z = 2 ; echo $x / $y / $z; ?>

Question 40 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php one = 1 ; two = 2 ; three = 3 ; four = 4 ; echo "one / two + three / four" ; ?>

✓ 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 →