Tell me in php, what are magic methods and how are they used?



Tell me in php, what are magic methods and how are they used?..

Answer / 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

More WordPress Interview Questions

How do I install https?

1 Answers  


How do you clear your browser?

1 Answers  


What is the difference between tags and categories?

1 Answers  


Are wordpress passwords salted?

1 Answers  


Why should I use wordpress for my website?

1 Answers  


Tell me what is the simplest way to find out the number of parameters passed into a function?

1 Answers  


What is a topic tag?

1 Answers  


How do I create a wordpress template?

1 Answers  


Do I own my wordpress domain?

1 Answers  


How do you set categories in wordpress?

1 Answers  


Would you initialize strings with single quotes or double quotes?

1 Answers  


What is plugin? List some important wordpress plugin?

1 Answers  


Categories