PHP Objective Practice Questions (MCQ) – Set 2

PHP objective practice questions for interviews. These output questions test how well you understand PHP and it’s programming methodology.


PHP Objective Practice Questions

Q1. What’s the output of following code.

a) 1
b) 2
c) 0


a) array(1) { [1]=> string(1) “b” }
b) array(1) { [1]=>1 ,[2]=> string(1) “b” }
c) array(1) { true=>1 ,[1]=> string(1) “b” }
d) None


a) 19
b) 5
d) 78

Q4. Which datatype will $a have at the end of the script

a) integer
b) string
c) char
d) bool

Q5. What’s the output ?

a) 0
b) 3
c) 4
d) 2

Q6. How to set Cookie in PHP. Choose the correct one.

a) cookie(name,value);
b) setcookie(name,value);
c) $cookie(name,value,time);
d) All of the above

Subscribe Our Tutorials

Get Latest Updates on Facebook

Q7. Which of the following statement are correct.

a) time() + 60*60*100 returns the current date and time plus two hour.
b) time() + 60*60 returns the current date and time plus one hour.
c) time() + 24*60*60 returns the current date and time plus one day.
d) Both b and c.


a) 4
b) 6
c) 5
d) 3


Q1. b) 2


Q2. a) array(1) { [1]=> string(1) “b” }

Q3. d) 78

Q4. b) string

Q5. c) 4

Q6. b) setcookie(name,value);

Read explanation of How to read,set,delete cookie in PHP .

Q7. d) Both b and c.

time() returns current Unix Timestamp. So when we add 60*60 then it’s current date and time plus one hour, similarly for c.

Q8 b) 6

If mode parameter in count is set to true, count() will recursively count the array.

How to Sort String in PHP.

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged , . Bookmark the permalink.