include_path 不适用于 PhpStorm
include_path won't work on PhpStorm
我有一个构造函数,我正在使用 include_path
,该函数如下所示:
public function __construct()
{
$url = $this->parseUrl();
if(file_exists('application\controllers'.$url[0].'.php')){
$this->controller=$url[0];
unset($url[0]);
}
require_once 'application\controllers'.$this->controller.'.php';
echo $this->controller;
}
不幸的是,当我尝试加载一个现有的控制器 url 像这样 http://localhost/project/public_html/home
我收到以下错误:
Warning: require_once(application\controllers home.php): failed to open stream: No such file or directory in C:\xampp\htdocs\project\application\core\App.php on line 24
Fatal error: require_once(): Failed opening required 'application\controllers home.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\project\application\core\App.php on line 24
我遵循了 documentation 并包含了路径:
C:\xampp\htdocs\project\application
和
C:\xampp\htdocs\project\application\controllers
但我仍然收到错误,我只是不知道为什么...有人可以帮助我吗?
但是路径中有一个 space...这正常吗?
你可以尝试使用 'application\controllers'(那里没有 space)吗?
而controllershome.php是文件名,或者controllers/home.php?
我有一个构造函数,我正在使用 include_path
,该函数如下所示:
public function __construct()
{
$url = $this->parseUrl();
if(file_exists('application\controllers'.$url[0].'.php')){
$this->controller=$url[0];
unset($url[0]);
}
require_once 'application\controllers'.$this->controller.'.php';
echo $this->controller;
}
不幸的是,当我尝试加载一个现有的控制器 url 像这样 http://localhost/project/public_html/home
我收到以下错误:
Warning: require_once(application\controllers home.php): failed to open stream: No such file or directory in C:\xampp\htdocs\project\application\core\App.php on line 24
Fatal error: require_once(): Failed opening required 'application\controllers home.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\project\application\core\App.php on line 24
我遵循了 documentation 并包含了路径:
C:\xampp\htdocs\project\application
和
C:\xampp\htdocs\project\application\controllers
但我仍然收到错误,我只是不知道为什么...有人可以帮助我吗?
但是路径中有一个 space...这正常吗? 你可以尝试使用 'application\controllers'(那里没有 space)吗? 而controllershome.php是文件名,或者controllers/home.php?