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.

strlen() returns the length of the string on success and . . . . if the string is empty.~!

A. -1
B. NULL
C. Garbage value
D. 0
Answer» E.
2.

The arguments in a function are evaluated from .....%!

A. left to right
B. right to left
C. sometimes left to right and sometimes right to left
D. Always right to left
Answer» B. right to left
3.

Returning values from functions may include .....%!

A. Arrays
B. Objects
C. Both A & B
D. None of above
Answer» D. None of above
4.

The below statement will return.$Var = substr(""abcdef"", -4, 1);%!

A. returns "f"
B. returns "d"
C. returns "c"
D. returns "cd"
Answer» D. returns "cd"
5.

It is always necessary to use parentheses with the print function.%!

A. True
B. False
Answer» C.
6.

¬¨‚Ä . . . . returns a new DateTime object.%!

A. getdate()
B. date_create()
C. date_sunrise()
D. date()
Answer» C. date_sunrise()
7.

What will be the output of the following PHP code?%!

A. Array ( [0] => Hello [0] => world. [0] => It’s [0] => a [0] => beautiful [0] => day. )
B. Array ( [0] => Hello [1] => world. [2] => It’s [3] => a [4] => beautiful [5] => day. )
C. Hello world. It’s a beautiful day
D. Array ( [1] => Hello [2] => world. [3] => It’s [4] => a [5] => beautiful [6] => day. )
Answer» C. Hello world. It‚Äö√Ñ√¥s a beautiful day
8.

What will be the output of the following PHP code?";}$function_holder = "sayHello";$function_holder();?>%!

A. No Output
B. Error
C. sayHello
D. HelloWorld
Answer» E.
9.

What will be the output of the following PHP code?%!

A. SaladSaladSaladSaladSalad is good
B. is good SaladSaladSaladSaladSalad
C. is good Salad
D. Salad is good
Answer» E.
10.

Which one of the following functions can be used to compress a string?%!

A. zip_compress()
B. zip()
C. compress()
D. gzcompress()
Answer» E.
11.

What will be the output of the following PHP code?%!

A. welcome to India
B. welcome to india
C. Welcome to India
D. Welcome to india
Answer» B. welcome to india
12.

What will be the output of the following PHP code ?%!

A. I am here to spoil this code
B. Error
C. My favourite TV show isI am here to spoil this code
D. None of the mentioned
Answer» C. My favourite TV show isI am here to spoil this code
13.

What will be the output of the following PHP code ?%!

A. Error
B. 0
C. 42
D. 84
Answer» C. 42
14.

What will be the output of the following PHP code?%!

A. Error
B. $msg
C. 0
D. Will this work
Answer» E.
15.

What will be the output of the following PHP code ?%!

A. Hello World
B. No Output
C. ERROR
D. None of the mentioned
Answer» B. No Output
16.

What will be the output of the following PHP code ?%!

A. contact
B. contact@examveda.com
C. @examveda.com
D. examveda.com
Answer» D. examveda.com
17.

*/*_Which of the following are valid function names?1. function()2. €()3. .function()4. $function()?

A. Only 2
B. None of the mentioned
C. All of the mentioned
D. 3 and 4
Answer» B. None of the mentioned
18.

*/*_Which one of the following functions can be used to compress a string??

A. zip_compress()
B. zip()
C. compress()
D. gzcompress()
Answer» E.
19.

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

A. contact
B. contact@examveda.com
C. @examveda.com
D. examveda.com
Answer» D. examveda.com
20.

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

A. Hello World
B. No Output
C. ERROR
D. None of the mentioned
Answer» B. No Output
21.

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

A. Error
B. 0
C. 42
D. 84
Answer» C. 42
22.

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

A. I am here to spoil this code
B. Error
C. My favourite TV show isI am here to spoil this code
D. None of the mentioned
Answer» C. My favourite TV show isI am here to spoil this code
23.

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

A. error
B. $msg
C. 0
D. will this work
Answer» E.
24.

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

A. welcome to India
B. welcome to india
C. Welcome to India
D. Welcome to india
Answer» B. welcome to india
25.

*/*_What will be the output of the following PHP code?";}$function_holder = "sayHello";$function_holder();?>?

A. No Output
B. Error
C. sayHello
D. HelloWorld
Answer» E.
26.

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

A. Array ( [0] => Hello [0] => world. [0] => It’s [0] => a [0] => beautiful [0] => day. )
B. Array ( [0] => Hello [1] => world. [2] => It’s [3] => a [4] => beautiful [5] => day. )
C. Hello world. It’s a beautiful day
D. Array ( [1] => Hello [2] => world. [3] => It’s [4] => a [5] => beautiful [6] => day. )
Answer» C. Hello world. It‚Äö√Ñ√¥s a beautiful day
27.

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

A. SaladSaladSaladSaladSalad is good
B. is good SaladSaladSaladSaladSalad
C. is good Salad
D. Salad is good
Answer» E.
28.

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

A. Error
B. 0
C. 42
D. 84
Answer» D. 84
29.

_ Which of the following PHP functions can be used for generating unique id’s?$?

A. uniqueid()
B. id()
C. md5()
D. mdid()
Answer» B. id()
30.

_ A function in PHP which starts with ______ (double underscore) is know as.$?

A. Magic Function
B. Inbuilt Function
C. Default Function
D. User Defined Function
Answer» B. Inbuilt Function
31.

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

A. Have a good day!
B. Have a good night!
C. ERROR
D. None of the mentioned
Answer» C. ERROR
32.

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

A. Hello World
B. No Output
C. ERROR
D. None of the mentioned
Answer» D. None of the mentioned
33.

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

A. Error
B. 0
C. 42
D. 84
Answer» B. 0
34.

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

A. TIME TO LIVE KING SIZE
B. Time to live king size
C. Uppercase
D. Time To Live King Size
Answer» E.
35.

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

A. helloblabla
B. error
C. hello
D. helloblablablabla
Answer» D. helloblablablabla
36.

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

A. I love my country
B. i love my Country
C. I love my Country
D. I Love My Country
Answer» E.
37.

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

A. Returned value from the function : $return_value
B. Error
C. Returned value from the function : 30
D. Returned value from the function :
Answer» D. Returned value from the function :
38.

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

A. Hello you! How are you today?
B. GREETING
C. GREETING, Hello you! How are you today?
D. “GREETING”,”Hello you! How are you today?”
Answer» B. GREETING
39.

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

A. What does /”yolo/” mean?
B. What does ”yolo” mean?
C. What does ”yolo” mean?
D. What does ”yolo” mean?
Answer» D. What does ‚Äö√Ñ√πyolo‚Äö√Ñ√π mean?
40.

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

A. O’Malley Wins The Heavyweight Championship!
B. O’malley Wins The Heavyweight Championship!
C. O’Malley wins the heavyweight championship!
D. o’malley wins the heavyweight championship!
Answer» E.
41.

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

A. Welcome to Narnia
B. greeting
C. GREETING
D. ERROR
Answer» B. greeting
42.

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

A. I am b
B. I am bI am a
C. Error
D. I am a Error
Answer» D. I am a Error
43.

_What will happen in this function call?$?

A. Call By Value
B. Call By Reference
C. Default Argument Value
D. Type Hinting
Answer» B. Call By Reference
44.

Which of the following PHP functions can be used to get the current memory usage?$?

A. get_usage()
B. get_peak_usage()
C. get_memory_usage()
D. get_memory_peak_usage()
Answer» D. get_memory_peak_usage()
45.

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

A. helloblabla
B. Error
C. hello
D. helloblablablabla
Answer» D. helloblablablabla
46.

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

A. 100
B. error
C. 75
D. 25
Answer» B. error
47.

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

A. I am here to spoil this code
B. Error
C. my favourite TV show is SherlockI am here ro spoil this code
D. None of the mentioned
Answer» D. None of the mentioned
48.

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

A. Case 1 was executed
B. Case 2 was executed
C. Default was executed
D. Case 4 was executed
Answer» E.
49.

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

A. Hello World
B. HelloWorld
C. Hell 0 Wo rld
D. World
Answer» C. Hell 0 Wo rld
50.

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

A. b is executedb is executedb is executed
B. b is executeda is executed
C. a is executed
D. b is executeda is executedb is executed
Answer» E.