SplAutoloader
in
Defines an interface for classes that may register with the spl_autoload registry
Table of Contents
Methods
- __construct() : mixed
- Constructor
- autoload() : mixed
- Autoload a class
- register() : void
- Register the autoloader with spl_autoload registry
- setOptions() : SplAutoloader
- Configure the autoloader
Methods
__construct()
Constructor
public
__construct([null|array<string|int, mixed>|Traversable $options = null ]) : mixed
Allow configuration of the autoloader via the constructor.
Parameters
- $options : null|array<string|int, mixed>|Traversable = null
autoload()
Autoload a class
public
autoload(string $class) : mixed
Parameters
- $class : string
Return values
mixed —False [if unable to load $class] get_class($class) [if $class is successfully loaded]
register()
Register the autoloader with spl_autoload registry
public
register() : void
Typically, the body of this will simply be:
spl_autoload_register(array($this, 'autoload'));
setOptions()
Configure the autoloader
public
setOptions(array<string|int, mixed>|Traversable $options) : SplAutoloader
In most cases, $options should be either an associative array or Traversable object.
Parameters
- $options : array<string|int, mixed>|Traversable