Explore topic-wise MCQs in Php.

This section includes 83 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

51.

With the introduction of namespaces, the same function name can be used in multiple places.%!

A. TRUE
B. FALSE
Answer» B. FALSE
52.

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

A. whattype()
B. showtype()
C. gettype()
D. settype()
Answer» D. settype()
53.

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

A. True
B. False
Answer» B. False
54.

Which of the following is not valid PHP code?%!

A. $_10
B. ${“MyVar”}
C. &$something
D. $10_somethings
E. $aVaR
Answer» E. $aVaR
55.

PHP is an open source software.%!

A. True
B. False
Answer» B. False
56.

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

A. Pond-sign
B. Yen-sign
C. Dollar-sign
D. Euro-sign
Answer» D. Euro-sign
57.

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

A. When the parameter is Boolean
B. When the function is being declared as a member of a class
C. When the parameter is being declared as passed by reference
D. When the function contains only one parameter
E. Never
Answer» D. When the function contains only one parameter
58.

Which version of PHP introduced Try/catch Exception?%!

A. PHP 4
B. PHP 5
C. PHP 5.3
D. PHP 6
Answer» C. PHP 5.3
59.

*/*_Which of the looping statements is/are supported by PHP?1. for loop2. while loop3. do-while loop4. foreach loop?

A. 1 and 2
B. 1, 2 and 3
C. All of the mentioned
D. None of the mentioned
Answer» D. None of the mentioned
60.

*/*_What will be the output of the following PHP code?echo ($a === $b);?>?

A. 5 === 5
B. Error
C. 1
D. False
Answer» D. False
61.

*/*_What will be the output of the following PHP code??

A. Error
B. 35 students
C. 35
D. 25 students
Answer» D. 25 students
62.

*/*_Which of following variables can be assigned a value to it?1. $3hello2. $_hello3. $this4. $This?

A. All of the mentioned
B. Only 2
C. 2, 3 and 4
D. 2 and 4
Answer» E.
63.

*/*_Which of the following must be installed on your computer so as to run PHP script?1. Adobe Dreamweaver2. PHP3. Apache4. IIS?

A. All of the mentioned.
B. Only 2
C. 2 and 3
D. 2, 3 and 4
Answer» E.
64.

_ What will be the output of the following PHP code?$?

A. I love arsenal
B. Error
C. I love arsenalI love manc
D. I love arsenalI love mancI love manu
Answer» D. I love arsenalI love mancI love manu
65.

_ What will be the output of the following PHP code?$?

A. get
B. true
C. false
D. clueget
Answer» E.
66.

_ What will be the output of the following PHP code?$?

A. 1
B. Error
C. 1234
D. 2
Answer» D. 2
67.

_ What will be the output of the following php code?$?

A. 3
B. 1+2
C. Error
D. 12
Answer» B. 1+2
68.

__Which of the following is/are a PHP code editor?1. Notepad2. Notepad++3. Adobe Dreamweaver4. PDT__

A. Only 4
B. All of the mentioned
C. 1, 2 and 3
D. Only 3
Answer» C. 1, 2 and 3
69.

_Which of the conditional statements is/are supported by PHP?1. if statements2. if-else statements3. if-elseif statements4. switch statements$?

A. Only 1
B. 1, 2 and 4
C. 2, 3 and 4
D. All of the mentioned.
Answer» E.
70.

_What will be the output of the following code?$?

A. 123
B. 111
C. 000
D. 011
Answer» B. 111
71.

_What will be the output of the following PHP code?$?

A. a
B. Error
C. $var
D. r
Answer» E.
72.

_What will be the output of the following php code?$?

A. 3
B. 1+2
C. 1.+.2
D. Error
Answer» C. 1.+.2
73.

PHP files have a default file extension of_______.$?

A. .html
B. .xml
C. .php
D. .ph
Answer» D. .ph
74.

What will be the output of the following PHP code?

A. What is her age? n She is $num years old
B. What is her age? She is $num years old
C. What is her age? She is 10 years old
D. What is her age?n She is 10 years old
Answer» B. What is her age? She is $num years old
75.

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”);$

A. 1 and 2
B. 1, 2 and 3
C. All of the mentioned
D. 1, 2 and 4
Answer» C. All of the mentioned
76.

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;

A. Both 1 and 2
B. All of the mentioned
C. Only 3
D. Only 1
Answer» D. Only 1
77.

What does PHP stand for?1. Personal Home Page2. Hypertext Preprocessor3. Pretext Hypertext Processor4. Preprocessor Home Page

A. Both 1 and 3
B. Both 2 and 4
C. Only 2
D. Both 1 and 2
Answer» E.
78.

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

A. $add = $add
B. $add = $add +$add
C. $add = $add + 1
D. $add = $add + $add + 1
Answer» C. $add = $add + 1
79.

What will be the output of the following code?

A. Error
B. My name is BobBob
C. My name is BobMy name is Bob
D. My name is Bob Bob
Answer» D. My name is Bob Bob
80.

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

A. Only 2
B. 1, 3 and 4
C. 2, 3 and 4
D. Both 2 and 4
Answer» D. Both 2 and 4
81.

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

A. It converts them to a common compatible data type and then compares the resulting values
B. It returns True only if they are both of the same type and value
C. If the two values are strings, it performs a lexical comparison
D. It bases its comparison on the C strcmp function exclusively
E. It converts both values to strings and compares them
Answer» B. It returns True only if they are both of the same type and value
82.

What is the value of $a and $b after the function call?

A. a is 3 and b is 4
B. a is 4 and b is 3
C. Both are 3
D. Both are 4
Answer» C. Both are 3
83.

What will be the output of the following PHP code?

A. AshleyBale
B. AshleyBaleBlank
C. ShrekBlank
D. Shrek
Answer» C. ShrekBlank