我刚刚开始开发一个代码点火器应用程序。
这个项目很简单,我只需要创建一个视图并从数据库中获取一些数据。
然而,当我尝试访问视图时,我总是会遇到这些错误。
我不知道这些错误是什么意思。
这是我用来在默认控制器类中加载视图的代码,它是一个独立于该类中索引函数的函数。
function watchlist(){
$this->load->view("watchlist_view");
}
以下是我在浏览器中访问视图的方式。
localhost/watchlist/index.php/home/watchlist
以下是我犯的错误。
A PHP Error was encountered
Severity: Warning
Message: session_start(): open(C:/xampp/session_data/localhost'sess_v4oapdmdqjq0s7b1i5j8mb8u95, O_RDWR) failed: No such file or directory (2)
Filename: helpers/session_helper.php
Line Number: 18
Fatal error: Call to undefined method Home::load() in C:'xampp'htdocs'watchlist'application'controllers'home.php on line 23
Warning: include(application/errors/error_php.php): failed to open stream: No such file or directory in C:'xampp'htdocs'watchlist'system'libraries'Exceptions.php on line 163
Warning: include(): Failed opening 'application/errors/error_php.php' for inclusion (include_path='.;C:'xampp'php'PEAR') in C:'xampp'htdocs'watchlist'system'libraries'Exceptions.php on line 163
Warning: include(application/errors/error_php.php): failed to open stream: No such file or directory in C:'xampp'htdocs'watchlist'system'libraries'Exceptions.php on line 163
Warning: include(): Failed opening 'application/errors/error_php.php' for inclusion (include_path='.;C:'xampp'php'PEAR') in C:'xampp'htdocs'watchlist'system'libraries'Exceptions.php on line 163
建造商家庭代码
class Home extends Controller
{
var $ministry_name = "Security";
function Home()
{
parent::Controller();
}
function index()
{
Removed local redirect. All sites will now redirect to main site
//Added a check to see if the user is still logged in. If so, remain on the site.
if (!$this->authorization->checklogin())
{
header('Location: http://mainsite.org/');
exit;
}
else
{
redirect("/home/main");
exit();
}
}
function watchlist(){
//Loads watchlist view
$this->load->view("watchlist_view");
}
请参阅https://ellislab.com/codeigniter/user-guide/general/controllers.html#constructors.在这里,应该扩展CI_Controller
而不是Controller
,并且可以使用通用构造函数__construct()
和parent::__constructor();
来代替旧的同名样式。