1.

Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?(a) $obj = new $foo;(b) $obj = new foo;(c) $obj = new foo ();(d) obj = new foo ();The question was posed to me in homework.This intriguing question comes from Basics of Object-Oriented PHP- 1 topic in division Object-Oriented PHP of PHP

Answer»

Correct answer is (c) $obj = NEW foo ();

BEST explanation: To create a new OBJECT in PHP we can USE the new statement to instantiate a CLASS.



Discussion

No Comment Found

Related InterviewSolutions