|
article.php 控制器
PHP复制代码
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Article extends CI_Controller {
function __construct ()
{
parent ::__construct ();
$this->load->helper('MY_others');
is_logged_in ('Article');
}
复制代码
MY_others_helper.php 自定义辅助函数
PHP复制代码
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('is_logged_in'))
{
function is_logged_in ($object)
{
$is_logged_in = $object->session->userdata('is_logged_in');
if(!isset($is_logged_in) || $is_logged_in != true)
{
echo 'You don\'t have permission to access this page. ';
echo anchor ('member/index','Login');
die();
}
}
}
复制代码
报错:
A PHP Error was encounteredSeverity: Notice
Message: Trying to get property of non-object
Filename: helpers/MY_others_helper.php
Line Number: 19
( ! ) Fatal error: Call to a member function userdata() on a non-object in E:\xampp\htdocs\ci_volunteers\app\helpers\MY_others_helper.php on line 19
应该怎么改?
|
|