rfc:function_autoloading4
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:function_autoloading4 [2024/09/03 21:07] – clarity and making the api more ergonomic withinboredom | rfc: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) { |
- | | + | $function_path = dirname(str_replace(' |
- | | + | $file = __DIR__ . '/ |
- | $file = __DIR__ . '/ | + | |
- | | + | |
- | require_once $file; | + | require_once $file; |
- | } | + | |
} | } | ||
}, false, false, SPL_AUTOLOAD_FUNCTION); | }, false, false, SPL_AUTOLOAD_FUNCTION); | ||
Line 64: | Line 62: | ||
The '' | The '' | ||
- | In the event that both constants are passed, it will attempt to autoload both types. This may be useful in the case where functions and invocable classes are used interchangeably. | + | In the event that both constants are passed, it will attempt to autoload both types. |
<code php> | <code php> |
rfc/function_autoloading4.1725397657.txt.gz · Last modified: 2024/09/03 21:07 by withinboredom