Problems with two autoload in PHP

0

Good I'm doing autoload without framework or composer anything else with php, then I saw in a blog that you could use two autoloads in the same folder, but when I apply it for two directories I get an error tells me

  

Warning: require_once (C: \ xampp \ htdocs \ Practice1 \ OOP \ exercise4 / model / Controler \ Controler.php): failed to open stream: No such file or directory in C: \ xampp \ htdocs \ Practice1 \ OOP \ exercise4 \ connections.php on line 6

     

Warning: require_once (C: \ xampp \ htdocs \ Practice1 \ OOP \ exercise4 / model / Controler \ Controler.php): failed to open stream: No such file or directory in C: \ xampp \ htdocs \ Practice1 \ OOP \ exercise4 \ connections.php on line 6

Conexiones.php is the file where I make the autoloads

function autoload($clase)
{
    $ruta = __DIR__.'/model/'.$clase.'.php';
    require_once $ruta;
}

function autoload2($clase)
{
    $ruta = __DIR__.'/'.$clase.'.php';
    require_once $ruta;
}

spl_autoload_register('autoload');
spl_autoload_register('autoload2');

$datos_db = ['dbname' => 'registro_estudiante', 'user' => 'root', 'pass' => ''];
extract($datos_db);
$conexionDB = new ConexionDB();
$conexion = $conexionDB->conexion($dbname, $user, $pass);

Controler\Controler::saludar();

By the way, if I use a single autoload if it works for me but with two I can not

    
asked by JOSE HERRADA 12.08.2018 в 18:58
source

0 answers