Skip to main content

Basic Php — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Basic 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 does PHP stand for? 1. Personal Home Page 2. Hypertext Preprocessor 3. Pretext Hypertext Processor 4. Preprocessor Home Page

Question 2 of 40
★ FPSC ★ PPSC

Which of the following is/are a PHP code editor? 1. Notepad 2. Notepad++ 3. Adobe Dreamweaver 4. PDT

Question 3 of 40
★ FPSC ★ PPSC

Which of the following must be installed on your computer so as to run PHP script? 1. Adobe Dreamweaver 2. PHP 3. Apache 4. IIS

Question 4 of 40
★ FPSC ★ PPSC

Which version of PHP introduced Try/catch Exception?

Question 5 of 40
★ FPSC ★ PPSC

We can use _________ to comment a single line? 1. /? 2. // 3. # 4. /* */

Question 6 of 40
★ FPSC ★ PPSC

Which of the following php statement/statements will store 111 in variable num? 1. int $num = 111; 2. int mum = 111; 3. $num = 111; 4. 111 = $num;

Question 7 of 40
★ FPSC ★ PPSC

What will be the output of the following php code? <?php $num = 1 ; $num1 = 2 ; print $num . "+" . $num1; ?>

Question 8 of 40
★ FPSC ★ PPSC

Which of following variables can be assigned a value to it? 1. $3hello 2. $_hello 3. $this 4. $This

Question 9 of 40
★ FPSC ★ PPSC

What will be the output of the following code? <?php $foo = 'Bob' ; $bar = & $foo; $bar = "My name is $bar" ; echo $bar; echo $foo; ?>

Question 10 of 40
★ FPSC ★ PPSC

Which of the following PHP statements will output Hello World on the screen? 1. echo (“Hello World”); 2. print (“Hello World”); 3. printf (“Hello World”); 4. sprintf (“Hello World”);

Question 11 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $color = "maroon" ; $var = $color [ 2 ] ; echo "$var" ; ?>

Question 12 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $score = 1234 ; $scoreboard = (array) $score; echo $scoreboard [ 0 ] ; ?>

Question 13 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $total = "25 students" ; $more = 10 ; $total = $total + $more; echo "$total" ; ?>

Question 14 of 40
★ FPSC ★ PPSC

Which of the below statements is equivalent to $add += $add ?

Question 15 of 40
★ FPSC ★ PPSC

Which statement will output $x on the screen?

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following code? <?php function track () { static $count = 0 ; $count ++ ; echo $count; } track () ; track () ; track () ; ?>

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $a = "clue" ; $a .= "get" ; echo "$a" ; ?>

Question 18 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $a = 5 ; $b = 5 ; span class = "sys-fun" >echo ( $a === $b ) ; ?>

Question 19 of 40
★ FPSC ★ PPSC

Which of the below symbols is a newline character?

Question 20 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $num = 10 ; echo 'What is her age? \n She is $num years old' ; ?>

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following PHP code? <?php $team = "arsenal" ; switch ( $team ) { case "manu" : echo "I love man u" ; case "arsenal" : echo "I love arsenal" ; case "manc" : echo "I love manc" ; } ?>

Question 22 of 40
★ 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 ) ; $x ++) { if ( $user [ $x ] == "Shrek" ) continue ; printf ( $user [ $x ]) ; } ?>

Question 23 of 40
★ FPSC ★ PPSC

If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?

Question 24 of 40
★ FPSC ★ PPSC

What is the value of $a and $b after the function call? <?php function doSomething ( & $arg ) { $return = $arg; $arg += 1 ; return $return; } $a = 3 ; $b = doSomething ( $a ) ; ?>

Question 25 of 40
★ FPSC ★ PPSC

PHP files have a default file extension of_______.

Question 26 of 40
★ FPSC ★ PPSC

Which of the conditional statements is/are supported by PHP? 1. if statements 2. if-else statements 3. if-elseif statements 4. switch statements

Question 27 of 40
★ FPSC ★ PPSC

Which of the looping statements is/are supported by PHP? 1. for loop 2. while loop 3. do-while loop 4. foreach loop

Question 28 of 40
★ FPSC ★ PPSC

Who is the father of PHP?

Question 29 of 40
★ FPSC ★ PPSC

How does the identity operator === compare two values?

Question 30 of 40
★ FPSC ★ PPSC

Under what circumstance is it impossible to assign a default value to a parameter while declaring a function?

Question 31 of 40
★ FPSC ★ PPSC

Variables always start with a ........ in PHP

Question 32 of 40
★ FPSC ★ PPSC

PHP is an open source software.

Question 33 of 40
★ FPSC ★ PPSC

Which of the following is not valid PHP code?

Question 34 of 40
★ FPSC ★ PPSC

PHP runs on different platforms (Windows, Linux, Unix, etc.)

Question 35 of 40
★ FPSC ★ PPSC

You can test the type of any variable with the ..... function.

Question 36 of 40
★ FPSC ★ PPSC

Assigning the empty string (like ' ') to a variable automatically renders it empty.

Question 37 of 40
★ FPSC ★ PPSC

If you echo a Boolean variable, the value FALSE displays as a .... and the value TRUE echoes as a .....

Question 38 of 40
★ FPSC ★ PPSC

When a simple data type is casted to an array, an array is created with the original value in the first element.

Question 39 of 40
★ FPSC ★ PPSC

String values must be enclosed in ......

Question 40 of 40
★ FPSC ★ PPSC

PHP does not support numbers written in hexadecimal, octal or scientific notation.

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