What is PHP's Autoloading?
Why Interviewers Ask This
Candidates at the intermediate level are expected to not only know this concept but explain the trade-offs involved. Interviewers use this question to see if you can reason about design decisions, not just recall facts.
Answer
Autoloading automatically loads class files when they are first used, eliminating the need for manual require or include statements. Register a custom autoloader with spl_autoload_register(function($class) { include str_replace("\\", "/", $class) . ".php"; });. In modern PHP, Composer's autoloader handles this automatically based on PSR-4 configuration in composer.json. PSR-4 maps namespaces to directories: "autoload": { "psr-4": { "App\\": "src/" } }. After running composer dump-autoload, including vendor/autoload.php makes all your classes available without any manual includes. This is how all modern PHP frameworks and packages work.
Common Mistake
Rushing to answer is a common mistake. Take two seconds to structure your response: definition → example → trade-off. This structure makes complex PHP answers easy to follow.