Home >Backend Development >PHP Tutorial >CI模板中php脚本的使用

CI模板中php脚本的使用

WBOY
WBOYOriginal
2016-06-23 13:52:13971browse

今天偶然发现,在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/
ss

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn