rfc:function_autoloading4

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
rfc:function_autoloading4 [2024/09/03 21:34] – remove weird line withinboredomrfc:function_autoloading4 [2024/09/04 19:07] (current) – fix example withinboredom
Line 30: Line 30:
 <?php <?php
  
-spl_autoload_register(function ($function, $type) { +spl_autoload_register(function ($function) { 
-    if ($type === SPL_AUTOLOAD_FUNCTION) { +    $function_path = dirname(str_replace('\\', DIRECTORY_SEPARATOR, $function)); 
-        $function_path = dirname(str_replace('\\', DIRECTORY_SEPARATOR, $function)); +    $file = __DIR__ . '/functions/' . $function_path . '.php';
-        $file = __DIR__ . '/functions/' . $function_path . '.php';+
  
-        if (file_exists($file)) { +    if (file_exists($file)) { 
-            require_once $file; +        require_once $file;
-        }+
     }     }
 }, false, false, SPL_AUTOLOAD_FUNCTION); }, false, false, SPL_AUTOLOAD_FUNCTION);
rfc/function_autoloading4.txt · Last modified: 2024/09/04 19:07 by withinboredom