PHP and autoloading · Question 6 of 12

What does an autoloader do in PHP?

1 answer is correct. Easy

Show answer

Answer

  • B It loads a class's file automatically as soon as the class is used for the first time

Explanation

Without an autoloader, every file would have to include its dependencies with require_once, which becomes confusing and error-prone with hundreds of classes. An autoloader is registered with spl_autoload_register() and steps in as soon as PHP encounters an unknown class; it then derives the file path from the class name and includes the file. Composer generates such an autoloader following the PSR-4 rules, which is why TYPO3 only loads the classes a request actually needs. The autoloader does not update packages; that is the job of composer update.

Certifications & exams

Which exam comes next?

You can already practise for 19 exams, and 21 are up for a vote. See all certifications with their official information, cast your vote or suggest your exam.

See all certifications