OOP Basics IV Flashcards
<p>
| What does the \_\_toString() magic method do?</p>
<p> It allows a class to decide how it will react when it is treated like a string. For example: 'echo $obj'.</p>
When is __call() triggered?
When invoking inaccessible methods in an object context.
When is __callStatic() triggered?
When invoking inaccessible methods in a static context.
What is a ‘shallow copy’?
With a shallow copy, a copy is made of each property that contains a value. However, any property that contains a reference to another object or resource remains a reference.
When you assign an object reference to a new variable, what is created?
A reference to the original object.
When is __set() invoked?
When writing data to undeclared or non-visible properties.
When is __get() invoked?
When reading data from undeclared or non-visible properties.
When is __isset() invoked?
When isset() or empty() is called on undeclared or non-visible properties.
When is __unset() invoked?
When unset() is used on undeclared or non-visible properties.
Does property overloading work in object context? Static context?
Only in object context, not in static.
When is __call() triggered?
When invoking inaccessible methods in an object context.
When is __callStatic() triggered?
When invoking inaccessible methods in a static context.