|
楼主 |
发表于 2009-12-27 11:10:04
|
显示全部楼层
我用了HMVC做了一个header模块
文件:modules/header/controllers/index.php
PHP复制代码
class Header_Index_module extends Module {
function __construct ()
{
parent ::__construct ();
}
function index ()
{
$this->load->library('session');
$userData = array(
'username' => $this->session->userdata('username'),
'email' => $this->session->userdata('email'),
);
$this->load->view('view_header',$userData);
}
}
复制代码
视图文件:modules/header/views/view_header.php
HTML复制代码
<div class="header">
<?php if($username): ?>
已经登录
<?php endif; ?>
</div>
复制代码
系统提示:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Header_Index_module:session
Filename: controllers/index.php
Line Number: 17 |
|