[英]spl_autoload_register instantiate classes
我們知道,自動加載您的類可以節省時間和代碼行。 我必須使用$config = new config();
實例化該類$config = new config();
為了使用那個加載的類。
spl_autoload_register(function($class) {
include $class . '.class.php';
});
是否可以使用spl_autoload_register
加載我的所有類,然后實例化所有這些類:
spl_autoload_register(function($class) {
include $class . '.class.php';
$class = new $class;
});
這沒有任何意義,因為每當您實例化一個對象時都會調用自動加載,而不是為了實例化新對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.