PHP扩展命名空间\类未知错误
这是我的父类代码:\core\controller\controlmasterPHP扩展命名空间\类未知错误,php,class,oop,namespaces,Php,Class,Oop,Namespaces,这是我的父类代码:\core\controller\controlmaster <?php namespace core\controller; class controlmaster{ private $model_base = null; //public function __construct(){ //always start session for any loaded controller //session_start(); //} p
<?php
namespace core\controller;
class controlmaster{
private $model_base = null;
//public function __construct(){
//always start session for any loaded controller
//session_start();
//}
public function _loadModels($models){
$file = dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR.$this->model_base.$models.".php";
$file_alloc = str_replace("\\","/",$file);
if(file_exists($file_alloc)){
require($file_alloc);
$models_name = $this->model_base.$models;
return new $models_name();
}
}
public static function _setModelBase($model_location){
$this->model_base = $model_location;
}
}
?>
这是应用程序:\applications\controller\index的我的控制器页面
<?php
namespace applications\controllers;
use core\configuration\configloader as config;
class index extends \core\controller\controlmaster{
public $config;
public function __construct(){
$this->config = new config;
$this->config->_parsePHP("j3mp_setting.php");
parent::_setModelBase($this->config->settings['app_model_base']); // Error doesn't appear when i comment this function
echo "This is main page and this is config for model app base : {$this->config->settings['base_url']}";
}
}
?>
这是core\configuration\configloader:
<?php
namespace core\configuration;
class configloader{
//Contains setting informations
public $inisettings;
public $settings;
public function _parseINI($file,$section){
$section = empty($section) ? false : true;
$file = __DIR__.DIRECTORY_SEPARATOR.$file;
if(file_exists($file)){
$parse = parse_ini_file($file,$section);
$this->inisettings = $parse;
}else{
throw new core\errorhandler\exception("File {$file} is not found in our system. Please contact administrator for details.","configloader");
}
}
public function _parsePHP($file){
$file = __DIR__.DIRECTORY_SEPARATOR.$file;
if(file_exists($file)){
$settings = array();
include($file);
$this->settings = $settings;
}else{
throw new core\errorhandler\exception("File {$file} is not found in our system. Please contact administrator for details.","configloader");
}
}
}
?>
当我注释parent::_setModelBase时。。。代码,错误消失,浏览器成功打印这是主页,这是模型应用程序库的配置:。我认为错误来自\core\controller\controlmaster,但我不知道如何修复它?我总是试图编辑文件\core\controller\controlmaster,但没有发生。。。如果发生错误,则消息“这是主页面…”。。。没有出来。。。你能告诉我错误是从哪里来的吗?谢谢…core\configuration\configloader的内容是什么?configloader用于加载配置文件,不应包括$file$此->设置=$settings;be$settings=include$file?调用\u setModelBase之前,$this->config->settings['app\u model\u base']的值是多少?@prodigitalson:使用静态或自存储时总是出错。。。