2016-05-22 3 views
-1

i veränderte Funktion von PHP 5.2 7.got stecken php aber nicht vertraut mit PHP 7Herausfinden, wie man Funktion zu PHP 7 ändert?

function custom_autoloader($className) //$className inside spl function 
{ 
if (file_exists(CORE_ROOT . '/includes/' . lcfirst($className) . '. class.php')) 
{ 
    spl_autoload_register('custom_autoloader') 


    //require_once(CORE_ROOT . '/includes/' . lcfirst($className) . '.class.php'); 
} 
}); 
+2

Nun ist es abwärtskompatibel, also gibt es keinen Grund, –

Antwort

0

PHP 7.1 wird noch älteren Code ausführen, aber man konnte die Scalar-Hinweise machen und Rückgabetypen wie Dies. Der ungültige Rückgabetyp war letztes Jahr merged.

function custom_autoloader(string $className) : void 
{ 
    if (file_exists(CORE_ROOT . '/includes/' . 
        lcfirst($className) . '.class.php')) { 
     spl_autoload_register('custom_autoloader') 

    } 
}); 
Verwandte Themen