Home > php教程 > PHP开发 > CI Framework Notes 1

CI Framework Notes 1

黄舟
Release: 2016-12-29 09:34:46
Original
1251 people have browsed it

class Home extends CI_Controller {
public function index(){
$this->load->view(" top ");
$this->load->view(" home.html "); 
$this->load->load(" foot "); 
}
}
//如果模板是html文件的话,就需要带.html后缀;如果是.php的话就不需要,$this->load->view(" home "); 
//也可以载入多个模板视图
//从文件夹里面载入多个视图
$this -> load -> view(" Index/top ");
$this -> load -> view(" Index/home ");
$this -> load -> view(" Index/footer ");
/**
* 分配给模板视图变量数据
*/
$data[' title '] = '你好 啊';
$this -> load -> view(" Index/top " ,$data );
注意:载入多个视图的时候,其中一个视图分配了数据变量的话,其他的视图也自动默认分配了数据变量
$data[ " name " ] = array(
" 张三 " , " 李四 " , " 王五 "
);
$this -> load -> view( " Index/home " , $data);
Copy after login

In view:

<?php echo $title; ?>
Copy after login



Load auxiliary function

1, manually load

$this -> load -> helper(" name ");
url , site_url , base_url
Copy after login
# in the controller ##2, automatic loading of auxiliary functions



$autoload[&#39;helper&#39;]=array(url);
Copy after login

3, shared functions are written in the system/core/common.php file


The above is The content of CI Framework Note 1. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!



Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template