CodeIgniter2.2.0-在控制器里调用load失败报错的问题
报错如下:
hello
A PHP Error was encountered Severity: Notice Message: Undefined property: Test::$load Filename: controllers/test.php Line Number: 9 Fatal error: Call to a member function view() on a non-object in D:\xampp\htdocs\citest\application\controllers\test.php on line 9
代码如下:
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class Test extends CI_Controller{
public function test()
{
//此处是引发错误的根源
echo 'hello';
}
public function index()
{
$this->load->view('test/index');
}
public function about()
{
$this->load->view('test/about');
}
protected function test1()
{
echo 'test protected function';
}
private function hello()
{
echo 'hello,ci';
}
public function test2()
{
$this->test1();
echo '<br/>';
$this->hello();
}
}
看到哪里错了吗?因为我重写了test控制器的构造函数,这和类名一样的public方法和__construct方法是一样的功能的,重写了之后CI_Controller父类里的实例化什么的都没了,必须自己实例化了。
除了把和类同名的方法移除外,还有中方法如下:
public function test()
{
echo 'hello';
parent::__construct();
}
public function index()
{
$this->load->view('test/index');
}
这样就没问题了。
时隔三年,重新使用codeigniter,忘却了许多事情。。。
CodeIgniter2.2.0-在控制器里调用load失败报错的问题的更多相关文章
- Bug集锦-Spring Cloud Feign调用其它接口报错
问题描述 Spring Cloud Feign调用其它服务报错,错误提示如下:Failed to instantiate [java.util.List]: Specified class is an ...
- pom.xml里有红叉报错的解决办法
pom.xml里有红叉报错的解决办法一: 1.把鼠标点在报的错上发现pom.xml报如下错误: Multiple annotations found at this line: - Failure t ...
- C# 调用win32 DLL报错 System.BadImageFormatException
C# 调用win32 DLL报错 System.BadImageFormatException 项目右键属性->项目设计器->生成->平台->把'默认设置(任何 CPU)'改 ...
- 调用python脚本报错/usr/bin/env: python : No such file or directory
一.调用python脚本报错 /usr/bin/env: python: No such file or directory 二.解决方法 原因是在windows上编写的脚本,使用dos2unix对脚 ...
- Intellij里检出svn报错找不到svn解决办法
Intellij里检出svn报错找不到,解决办法: 1. 安装svn客户端: 2. 去掉settings->version control->subversion里的use command ...
- asp.net使用wsdl文件调用接口,以及调用SSL接口报错“根据验证过程 远程证书无效”的处理
1.调用wsdl接口,首先需要将wsdl文件转换为cs文件: 进入VS 开发人员命令提示行,输入如下命令: c:/Program Files/Microsoft Visual Studio 8/VC& ...
- 2018最新win10 安装tensorflow1.4(GPU/CPU)+cuda8.0+cudnn8.0-v6 + keras 安装CUDA失败 导入tensorflow失败报错问题解决
原文作者:aircraft 原文链接:https://www.cnblogs.com/DOMLX/p/9747019.html 基本开发环境搭建 1. Microsoft Windows 版本 关于W ...
- java调用Linux命令报错:java.io.IOException: Cannot run program "ps": CreateProcess error=2, ?????????
在idea里面,java代码:Runtime.getRuntime().exec("ps -aux") 是因为默认是用windows平台运行了,所以报错,得改成调用Linux平台运 ...
- [Android自动化] 在 pip-9.0.1 版本情况下安装 uiautomator2 报错的解决办法
1.在命令窗口中使用命令: pip install uiautomator2 时报 pip 版本过低,需要先升级 pip 版本,理论上会按照提示进行升级 pip 操作,但执行升级命令时到最后却还是报错 ...
随机推荐
- thinkpad e450 win7黑苹果macos 10.10.5(网/显/声卡驱动)安装成功
首先上图: 过程: 1.使用变色龙安装macos 10.10.5懒人版黑苹果 2.使用Haswell破解内核替换,成功进入系统 2.5.使用Hackintosh Vietnam Tool 1.9.6以 ...
- 转:亿级Web系统的高容错性实践(好博文)
亿级Web系统的高容错性实践 亿级Web系统的高容错性实践 背景介绍 大概三年前,我在腾讯负责的活动运营系统,因为业务流量规模的数倍增长,系统出现了各种各样的异常,当时,作为开发的我,7*24小时地没 ...
- Getting Started With Hazelcast 读书笔记(第七章)
第七章 部署策略 Hazelcast具有适应性,能根据不同的架构和应用进行特定的部署配置,每个应用可以根据具体情况选择最优的配置: 数据与应用紧密结合的模式(重点,of就是这种) 胖客户端模式(最好用 ...
- [php-src]Php扩展的多文件编译
内容均以php5.6.14为例. 假设有模块 foo,php_foo.h 和 foo.c 是固有文件,额外的C文件如果要加入编译,大致有五步. 1. 新增头文件 foo_bar.h #ifndef F ...
- 清空StringBuilder的三种方法及效率
清空StringBuilder的三种方法及效率 大家知道对于字符串频繁拼接是使用stringbuilder.Append方法比使用string+=方法效率高很多,但有时需要清空stringbuilde ...
- Ajax Step By Step1
Ajax 最关键的地方,就是实现异步请求.接受响应及执行回调. jQuery 对 Ajax 做了大量的封装,不需要去考虑浏览器兼容性, 对于封装的方式,jQuery 采用了三层封装:最底层的封装方法为 ...
- python核心编程笔记
1.python的对象是通过引用传递的. 2.多元赋值: x, y = y, x
- 一台MySQL服务器启动多个端口
一台MySQL服务器启动多个端口 在测试Mysql多主一从服务器,即一个从服务器多端口同步不同主库.本文记录了开启不同端口的操作. 详细步骤: 1.首先要先把my.cnf配置文件复制一份,开几个端口要 ...
- jQuery - 自定义伪类 [:pseudoclass]
有两种创建伪类的方法, 第一种, $.extend( $.expr[':'], { // 自定义的伪类名称:group group: function(element, index, matches, ...
- Notes for Studying Django
Once you added a new application to INSTALLED_APPS, the database tables need to be updated, thus you ...