There is an open book survey for the work app I am doing, and he clearly highlighted a flaw in my php knowledge.
Note that I am not asking for an answer directly, I am asking you to show that I misunderstand / don’t know how to answer it. The question arises:
3. Finish the following class to print "Person->name has been zapped" when the following is executed on a Person object: print $person; class Person{ private $name = ''; public function __construct($name){ $this->name = $name; } } $person = new Person('fred'); print $person; // fred has been zapped
Now either there is a way to add exception handling to the class (although I would have thought that “printing” would be the one that throws the exception, or I just misunderstood the question. I know (from a quick test), resulting in printing in the try file .. catch still crashes the program with a "perceptible fatal error" (my catch did not work).
What should i read?
David
source share