The spl_autoload_functions Function

The spl_autoload_functions function returns an array of all autoload functions registered with spl_autoload_register. If no autoloaders are registered, the function will return an empty array.

Syntax

phpspl_autoload_functions();

Example

Let's check the list of registered autoloaders without registration:

php<?php
  $res = spl_autoload_functions();
  print_r($res);
?>

Code execution result:

php[]

Example

Let's register an autoloader and check the result:

php<?php
  function my_autoload($class) {
    include $class . '.php';
  }
  
  spl_autoload_register('my_autoload');
  $res = spl_autoload_functions();
  print_r($res);
?>

Code execution result:

php['my_autoload']

Example

Let's check several registered autoloaders:

php<?php
  function autoload1($class) {
    // implementation 1
  }
  
  function autoload2($class) {
    // implementation 2
  }
  
  spl_autoload_register('autoload1');
  spl_autoload_register('autoload2');
  $res = spl_autoload_functions();
  print_r($res);
?>

Code execution result:

php['autoload1', 'autoload2']

See Also