Thinkphp:

在子控制器里面写了一个构造函数,如下

//构造函数
public function __construct(){
echo 1;
}

结果页面报错了  ---->  Call to a member function assign() on null

然后去继承的父类里面一看,原来里面写了一个_initialize()的方法,原来是子类的构造函数覆盖了父类的,所以报错了,所以需要继承一下父类的构造函数:

parent::__construct();  

其实_initialize()是TP封装的方法,和PHP自带的__construct()方法是差不多一样的,不过有一点区别,那就是_initialize() 它会帮我们自己继承父类的构造函数,而__construct()源生自带的,需要自己去继承父类构造函数。

Call to a member function assign() on null的更多相关文章

  1. PHP Lumen Call to a member function connection() on null 报错

    (1/1) Error Call to a member function connection() on nullin Model.php line 1201at Model::resolveCon ...

  2. Call to a member function allowField() on null 错误总结

    Call to a member function allowField() on null 在空对象上调用  allowField() 没有该模型对象无法调用,需要创建相应的模型 错误版本: if ...

  3. 解决ThinkPHP Call to a member function assign() on a non-object

    <ignore_js_op> assign是tp模板输出变量的一个方法.没有object只能说没实例化...<ignore_js_op> 经过几番思索,终于发现了.原来是Act ...

  4. Call to a member function assign() on a non-object;thinkphp中报错

    这个在自己写的类中 需要function __construct(){parent::__construct();}继承父类构造函数 当发生这个错误的时候,需要在构造函数中集成父类构造

  5. 显示Class 'Think\Controller\FuController' not found和Call to a member function assign() on a non-object 的错误问题

    Class 'Think\Controller\FuController' not found 错误位置 FILE: D:\wamp\www\tinkphp\Application\Come\Cont ...

  6. Wordpress 数据库查询错误 Call to a member function get_results() on null

    在插件中的一个文件使用如下代码,无法查询 <body> <?php global $wpdb; $sql = ""; $sql = "SELECT * ...

  7. laravel和lumen数据库链接错误_FatalErrorException Call to a member function connection

    FatalErrorException in Model.php line 3339: Call to a member function connection() on null 挺简单的一个lum ...

  8. Call to a member function cellExists() on a non-object /phpexcel/Classes/PHPExcel/Calculation.php on line 3241

    PHP Fatal error: Call to a member function cellExists() on a non-object in /home/edata/eframework/we ...

  9. Thinkphp---------Call to a member function free_result() on a non-object

    1.平时用框架用久了,直接执行原生的sql反而做起来反应迟钝了.今天遇到一个问题,就是直接执行一个添加的sql语句,然后我用了TP框架的M()->query();方法.运行以后,会报Call t ...

随机推荐

  1. 关于提交表单时添加自定义值的方式:data中值可绑定function

    表单提交时新增自定义值: $.ajaxForm(){ data:{aaa:"12"} } 但是这个是在初始化的时候就绑定进去的,所以值是固定的初始化时候的值,若想添加动态值,可以这 ...

  2. [LeetCode 题解]: Add Two Numbers

    You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...

  3. ManualResetEvent 线程通信

    using System; using System.Threading; namespace ConsoleApp1 { class MyThread { Thread t = null; Manu ...

  4. 图形学思考 - 聊聊透视图投射矩阵perspective projective matrix

    from:版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/,未经本作者允许不得转载. 什么是透视图投射矩阵perspective projective ...

  5. random 随机生成字符串

    # import random# for x in range(10):# i = 0# l = []# while i < 10:# ret = chr(random.randint(33, ...

  6. code::blocks学习(2)

    转自: http://blog.csdn.net/sinat_27088253/article/details/52137855 http://jingyan.baidu.com/article/0b ...

  7. Chat Order (map映射)

     Chat Order Time Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit ...

  8. BZOJ2243 [SDOI2011]染色(LCT)

    传送门 明明是道树剖的题…… 然而我硬生生做成了LCT 虽然的确用LCT只是板子啦(LCT的题哪道不是板子) 就是把颜色打上标记,然后基本就是板子 //minamoto #include<bit ...

  9. [Flex] 组件Tree系列 —— 运用LabelFunction hasChildren getChildren设置Tree包含节点个数

    mxml: <?xml version="1.0" encoding="utf-8"?> <!--功能描述:运用LabelFunction h ...

  10. ubuntu15.04下安装jdk8

    前几天手贱,删掉了ubuntu自带的java,最后安装时遇到了Picked up JAVA_TOOL_OPTIONS的问题,经过网上各种找,终于被我弄成功了.下面将经验下载下面供大家方便: jdk8的 ...