Explore topic-wise MCQs in Php.

This section includes 8 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 method is invoked when an undefined property is accessed?

A. __get()
B. __isset()
C. __unset()
D. __undefined()
Answer» B. __isset()
2.

__clone() is run on the ___ object.

A. original
B. pseudo
C. external
D. copied
Answer» E.
3.

What will be the output of the following PHP code? (Before the version PHP 5.2)

A. Object Not Found
B. Object id #1
C. PHP Catchable fatal error
D. Cannot initialize objectView Answer
Answer» C. PHP Catchable fatal error
4.

Which keyword must be added before $first variable on the third line of the above question to make $second and $first as distinct objects in PHP 5?

A. copy
B. clone
C. cut
D. Can’t add any word to make them distinct
Answer» C. cut
5.

Which one of the following PHP statements is true?

A. In PHP 4: $second and $first are 2 distinct objects
B. In PHP 5: $second and $first are 2 distinct objects
C. In PHP 4: $second and $first refer to one object
D. None of the mentionedView Answer
Answer» B. In PHP 5: $second and $first are 2 distinct objects
6.

Which method introduced in PHP 5, is invoked just before an object is a garbage collected?

A. __collect()
B. __garbage()
C. __destruct()
D. __destructor()
Answer» D. __destructor()
7.

Which one of the following method is invoked when an undefined method is called by client code?

A. __get()
B. __isset()
C. __unset()
D. __call()
Answer» E.
8.

Which one of the following method is invoked when a value is assigned to an undefined property?

A. __get()
B. __set()
C. __isset()
D. __call()
Answer» C. __isset()