What are 'Magic Methods' in PHP, and can you name a few common ones?

Last updated 15 June 2026

  • Magic methods are __-prefixed methods PHP calls automatically on certain object events.

  • Common ones: __construct, __destruct, __get/__set (inaccessible properties), __call/__callStatic (inaccessible methods), __toString, __invoke.

  • They add flexibility but can hurt readability, IDE autocompletion and performance.

  • https://www.turing.com/interview-questions/php
  • https://harinathr95.medium.com/full-stack-developer-interview-questions-2-php-laravel-4c5e3c6cf66a
All PHP interview questions