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.

1.

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

A. ll of the mentioned.
B. nly 2
C. and 3
D. , 3 and 4
Answer» E.
2.

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

A. nly 4
B. ll of the mentioned
C. , 2 and 3
D. nly 3
Answer» C. , 2 and 3
3.

PHP files have a default file extension of_______.

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

As the namespace size grows, using namespaces can become a little repetitious, but PHP also provides the . . . . . statement, which allows you to alias a specific namespace.

A. hp
B. rant
C. se
D. abel
Answer» D. abel
5.

Multiple namespaces cannot be defined in the same file.

A. RUE
B. ALSE
Answer» C.
6.

Which of the below namespace declaration is correct?

A. amespace ORA:
B. amespace 1_RA;
C. amespace ORA;
D. amespace ORA_#;
Answer» D. amespace ORA_#;
7.

Within a namespace, for accessing the built-in PHP classes you can prefix the class name with a . . . . . and let PHP look in the global class list.

A. ercent
B. mpersand
C. sterix
D. ackslash
Answer» E.
8.

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

A. RUE
B. ALSE
Answer» B. ALSE
9.

It is possible to create a hierarchy of namespaces in PHP.

A. RUE
B. ALSE
Answer» C.
10.

All classes in the same namespace or subnamespace don’t have to the declared in the same PHP file.

A. RUE
B. ALSE
Answer» B. ALSE
11.

Some PHP code might not have a namespace and therefore lives in the . . . . . . namespace.

A. efault
B. lobal
C. RE
D. utomatic
Answer» C. RE
12.

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

A. ll of the mentioned
B. nly 2
C. , 3 and 4
D. and 4
Answer» E.
13.

What will be the output of the following PHP code?

A. rror
B. 5 students
C. 5
D. 5 students
Answer» D. 5 students
14.

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. and 2
B. , 2 and 3
C. ll of the mentioned
D. , 2 and 4
Answer» C. ll of the mentioned
15.

What will be the output of the following code?

A. rror
B. y name is BobBob
C. y name is BobMy name is Bob
D. y name is Bob Bob
Answer» D. y name is Bob Bob
16.

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

A. === 5
B. rror
C.
Answer» D.
17.

What will be the output of the following PHP code?

A. et
B. rue
C. alse
D. lueget
Answer» E.
18.

What will be the output of the following code?

A. 23
B. 11
C. 00
D. 11
Answer» B. 11
19.

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

A. and 2
B. , 2 and 3
C. ll of the mentioned
D. one of the mentioned
Answer» D. one of the mentioned
20.

What will be the output of the following PHP code?

A. love arsenal
B. rror
C. love arsenalI love manc
D. love arsenalI love mancI love manu
Answer» D. love arsenalI love mancI love manu
21.

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

A. nly 1
B. , 2 and 4
C. , 3 and 4
D. ll of the mentioned.
Answer» E.
22.

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

A. is 3 and b is 4
B. is 4 and b is 3
C. oth are 3
D. oth are 4
Answer» C. oth are 3
23.

What will be the output of the following PHP code?

A. shleyBale
B. shleyBaleBlank
C. hrekBlank
D. hrek
Answer» C. hrekBlank
24.

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

A. ingle quotes
B. ouble quotes
C. oth A and B
D. one of above
Answer» D. one of above
25.

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

A. rue
B. alse
Answer» B. alse
26.

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

A. , 1
B. lank string, 2
C. mpty variable, 1
D. lank string, 1
Answer» E.
27.

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

A. rue
B. alse
Answer» C.
28.

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

A. hattype()
B. howtype()
C. ettype()
D. ettype()
Answer» D. ettype()
29.

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

A. rue
B. alse
Answer» B. alse
30.

Which of the following is not valid PHP code?

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

PHP is an open source software.

A. rue
B. alse
Answer» B. alse
32.

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

A. ond-sign
B. en-sign
C. ollar-sign
D. uro-sign
Answer» D. uro-sign
33.

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

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

PHP considers the following values as False

A. he integer 0
B. he one-character string 0
C. onstant NULL
D. oth A and B
E. ll of Above
Answer» F.
35.

What is the limit of a PHP integer value?

A. 6384
B. 5536
C. 048576
D. 147483647
Answer» E.
36.

strval()

A. ccepts a value and converts it into a string array
B. ccepts a value and converts it into an string dictionary
C. ccepts a value and converts it into string equivalent
D. one of above
Answer» D. one of above
37.

PHP ..... demand that you declare a data type when you create a variable.

A. oes
B. oes not
Answer» C.
38.

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

A. rue
B. alse
Answer» C.
39.

The value of __NAMESPACE__ is a string that contains the current namespace name. In global, un-namespaced code, it contains . . . . . .%!

A. NULL
B. 0
C. an empty string
D. gibberish value
Answer» D. gibberish value
40.

It is possible to create a hierarchy of namespaces in PHP.%!

A. TRUE
B. FALSE
Answer» C.
41.

All classes in the same namespace or subnamespace don’t have to the declared in the same PHP file.%!

A. TRUE
B. FALSE
Answer» B. FALSE
42.

Some PHP code might not have a namespace and therefore lives in the . . . . . . namespace.%!

A. Default¬¨‚Ä
B. Global
C. PRE
D. Automatic
Answer» C. PRE
43.

As the namespace size grows, using namespaces can become a little repetitious, but PHP also provides the . . . . . statement, which allows you to alias a specific namespace.%!

A. php
B. grant
C. use
D. label
Answer» D. label
44.

String values must be enclosed in ......%!

A. single quotes
B. double quotes
C. both A and B
D. none of above
Answer» D. none of above
45.

Multiple namespaces cannot be defined in the same file.%!

A. TRUE
B. FALSE
Answer» C.
46.

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

A. True
B. False
Answer» B. False
47.

Which of the below namespace declaration is correct?%!

A. namespace ORA:
B. namespace 1_RA;
C. namespace ORA;
D. namespace ORA_#;
Answer» D. namespace ORA_#;
48.

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

A. 0, 1
B. blank string, 2
C. empty variable, 1
D. blank string, 1
Answer» E.
49.

Within a namespace, for accessing the built-in PHP classes you can prefix the class name with a . . . . . and let PHP look in the global class list.%!

A. percent
B. ampersand
C. asterix
D. backslash
Answer» E.
50.

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

A. True
B. False
Answer» C.