Tell me in php, what are magic methods and how are they used?
Answer Posted / Kumar Aman
Magic methods, also known as 'magic functions', are special PHP functions that automatically trigger when certain events occur. Magic methods begin and end with double underscores (__). Some examples include: 1) __construct(): runs whenever an object is instantiated. 2) __destruct(): runs right before the script ends or an object is destroyed. 3) __get($name): automatically generates a method to access public properties when they are called by their property name.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers