CI模板中php脚本的使用

来源:互联网 发布:南昌房地产交易数据 编辑:程序博客网 时间:2024/05/21 04:44

今天偶然发现,在CI的模板中能够直接使用CI自带的函数,并且可以直接调用controller里面的属性。案例:

控制器:

public function test(){     $this->a = 'aaa';     $this->load->view('member/test',$data);} 

模板:

<?php var_dump($this->a);?><?php echo base_url();?><br><?php echo $this->uri->segment(4);?>
输入url:trunk.com/member/index/test/bbb

打印结果:

string 'aaa' (length=3)
http://trunk.com/
bbb

0 0