
function __autoload en php
Publicado por Gustavo (4 intervenciones) el 05/03/2024 13:07:27
hola amigos, esta funcion esta obsoleta a, tengo entendido que se debe cambiar por spl_autoload_register , necesito ayuda para configurarla por favor.
function __autoload($class_name) {
$Registy = Registry::getInstance();
foreach($Registy->autoload['paths'] as $path) {
$filepath = $path . '/' . strtolower($class_name) . '.class.php';
// echo '<br> ---------------------------------------- $filepath '.$filepath;
if(is_file($filepath)) {
require_once $filepath;
break;
}else{
// echo '<br> ////////////////////////////////// ERROR ';
}
}
}
spl_autoload_register(function($class){
//
require_once($class.'.php');
});
$Second = new Second;
$Second->run_second();
$First = new First;
$First->run_first();
function __autoload($class_name) {
$Registy = Registry::getInstance();
foreach($Registy->autoload['paths'] as $path) {
$filepath = $path . '/' . strtolower($class_name) . '.class.php';
// echo '<br> ---------------------------------------- $filepath '.$filepath;
if(is_file($filepath)) {
require_once $filepath;
break;
}else{
// echo '<br> ////////////////////////////////// ERROR ';
}
}
}
spl_autoload_register(function($class){
//
require_once($class.'.php');
});
$Second = new Second;
$Second->run_second();
$First = new First;
$First->run_first();
Valora esta pregunta


0