説明の仕方がわかりませんが、頑張ります。わかりました、私はこれらの3つのファイルを持っています:
Theme.php
path: /shared/models/Theme.php class: Theme namespace: namespace models;
Custom.php
path: /themes/default/Custom.php class: Custom namespace: this class does not use namespace
Settings.php
path: /controllers/Settings.php class: Settings namespace: this class does not use namespace
私のようにSettings.php
見えます:
<?php
class Settings
{
public function apply()
{
$theme = new \models\Theme();
$theme->customize(); // in this method the error is triggered
}
}
Theme
次に、以下のクラスを見てください。
<?php
namespace models;
class Theme
{
public function customize()
{
$ext = "/themes/default/Custom.php";
if (file_exists($ext))
{
include $ext;
if (class_exists('Custom'))
{
$custom = new Custom();
//Here, $custom var in null, why???
}
}
}
}
コードを実行すると、次のエラーが発生します。
Message: require(/shared/models/Custom.php) [function.require]: failed to open stream: No such file or directory
Line Number: 64
インタプリタがvarCustom
で指定するのではなく、別のディレクトリからクラスをロードしようとするのはなぜですか?$ext