spl_autoload_functions

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

spl_autoload_functionsRetorna todas as funções __autoload() registradas

Descrição

spl_autoload_functions(): array

Obtém todas as funções __autoload() registradas.

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

Um array de todas as funções __autoload() registradas. Se nenhuma função estiver registrada, ou a fila de autoload não estiver ativada, então o valor de retorno será um array vazio.

Registro de Alterações

Versão Descrição
8.0.0 O valor de retorno foi atualizado para sempre ser um array; anteriormente, esta função retornava false se a fila de autoload não estivesse ativada.
adicione uma nota

Notas Enviadas por Usuários (em inglês) 2 notes

up
7
dantedantas at gmail dot com
8 years ago
If you use an anonymous function, it will return the object that are expected.spl_autoload_register(function ($myclass){    $keyclass = substr($myclass, 0, 1);    switch ($keyclass) {        case 'c':            if (file_exists("class".DIRECTORY_SEPARATOR.$myclass.".php") === true)                require_once ("class".DIRECTORY_SEPARATOR.$myclass.".php");            break;        case 'i':            if (file_exists("interface".DIRECTORY_SEPARATOR.$myclass.".php") === true)                require_once ("interface".DIRECTORY_SEPARATOR.$myclass.".php");            break;        case 'a':            if (file_exists("abstract".DIRECTORY_SEPARATOR.$myclass.".php") === true)                require_once ("abstract".DIRECTORY_SEPARATOR.$myclass.".php");            break;        default:            if (file_exists($myclass.".php") === true)                require_once ($myclass.".php");    }/******************************/var_dump(spl_autoload_functions()) return:array(1) {  [0]=>  object(Closure)#1 (1) {    ["parameter"]=>    array(1) {      ["$myclass"]=>      string(10) "<required>"    }  }}
up
5
124307954 at qq dot com
6 years ago
<?phpspl_autoload_register(function ($name) {    echo "Want to load $name.\n";   });spl_autoload_register(function($className) {    var_dump($className);});function unregister($className) {    var_dump($className.' i will be the first');}spl_autoload_register('unregister');var_dump(spl_autoload_functions());===================array(3) {  [0]=>  object(Closure)#1 (1) {    ["parameter"]=>    array(1) {      ["$name"]=>      string(10) "<required>"    }  }  [1]=>  object(Closure)#2 (1) {    ["parameter"]=>    array(1) {      ["$className"]=>      string(10) "<required>"    }  }  [2]=>  string(10) "unregister"}
To Top