Complete the code to include a class file manually.
<?php require_once '[1]'; $class = new MyClass(); ?>
You need to include the class file manually using require_once with the class filename.
Complete the code to register an autoloader function.
<?php spl_autoload_[1]('myAutoloader'); function myAutoloader($class) { include $class . '.php'; } ?>
The correct function to register an autoloader is spl_autoload_register. Here, the blank is for the part after spl_autoload_, so the correct answer is register.
Fix the error in the autoloader function to correctly load class files.
<?php spl_autoload_register(function($class) { include '[1]' . $class . '.php'; }); ?>
The autoloader should include the correct path prefix. Using "./" means current directory, which is common if class files are in the same folder.
Fill both blanks to create an autoloader that loads classes from the 'lib' folder and appends '.class.php' extension.
<?php spl_autoload_register(function($class) { include "[1]" . $class . "[2]"; });
The autoloader includes files from the 'lib/' folder and uses the '.class.php' extension for class files.
Fill all three blanks to create an autoloader that loads classes from 'src/', converts class names to lowercase, and appends '.php'.
<?php spl_autoload_register(function($class) { $file = "[1]" . strtolower([2]) . "[3]"; include $file; });
The autoloader builds the file path by prefixing 'src/', converting the class name to lowercase, and appending '.php'.