dongshao1981 2016-03-19 07:32
浏览 397
已采纳

每次有构造函数都被称为“parent :: __ construct(); “在模型和控制器上。 为什么用它?

Here is the constructor invocation. There is nothing is passed or no function is called in constructor. why it is called?

class admin_login_model extends CI_Model {

function __construct() {
    parent::__construct();
}

on controller

class admin_login extends CI_Controller {

function __construct() {
    parent::__construct();

    // if(!$this->session->userdata('validated')) redirect('admin/admin_login');
}

}
  • 写回答

2条回答 默认 最新

  • doulu6314 2016-03-19 07:39
    关注

    checking every page user session exist or not .like this .if you use the constructor .when every page calling constructor execute first and give out put true. then go to the function so that there we checking user session exist or not like this checking

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 把Excel导入MATLAB显示错误怎么解决?
  • ¥15 Java中消息和缓存如何使用
  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx