2021年3月13日解決済み

namespace を使用するとクラスの自動読み込みはできなくなりますか?

ユーザー

namespaceを使用すると自動読み込みはできなくなりますか?

例:

// require('Post.php');
spl_autoload_register(function($class){
    require($class . '.php');
});

class Post{}

$posts[0] = new Dotinstall\MyPHPApp\Post('hello');
$posts[1] = new Dotinstall\MyPHPApp\Post('hello again');

foreach ($posts as $post) {
  $post->show();
}
スタッフ

この回答を見るにはプレミアムプランへの登録が必要です

プレミアムプランとは?