search
Homephp教程PHP开发CI Framework Notes 1

CI Framework Notes 1

Dec 29, 2016 am 09:34 AM
ci framework

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);

In view:

<?php echo $title; ?>



Load auxiliary function

1, manually load

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



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

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)!



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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools