欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

CodeIgniter生成靜態(tài)頁的方法

 更新時(shí)間:2016年05月17日 12:05:21   作者:yanhui_wei  
這篇文章主要介紹了CodeIgniter生成靜態(tài)頁的方法,涉及CodeIgniter框架使用文件操作類生成靜態(tài)文件的實(shí)現(xiàn)技巧,需要的朋友可以參考下

本文實(shí)例講述了CodeIgniter生成靜態(tài)頁的方法。分享給大家供大家參考,具體如下:

現(xiàn)在我們來開發(fā)如何讓CI框架生成靜態(tài)頁面.下面直接帖代碼:

$this->output->get_output();

使用這個方法,你可以可以得到將要輸出的數(shù)據(jù),并把它保存起來,留著它用(我們做新聞類型網(wǎng)站的時(shí)候,常常需要生成靜態(tài)的HTML文件).

$string = $this->output->get_output();
$this->load->helper('file');
write_file('./lianglong_codeigniter.html', $string);

比如我們要輸出的頁面是要加載某個視圖后的數(shù)據(jù),那么我們就在

$this->load->view('welcome_lianglong);

之后加入

$this->output->get_output();

并把值給一個變量如$lianglong存儲起來.再用CI的FILE中的write_file輔助函數(shù),生成你要的文件,如下例

function sc(){
 $this->load->helper('file');
 $this->load->view('welcome_message');
 $lianglong=$this->output->get_output();
 if ( !write_file('./lianglongfile.html', $lianglong))
 {
  echo 'Unable to write the file';
 }
 else
 {
  echo 'File written!';
 }
}

或者:

function sc(){
 $this->load->helper('file');
 $liangdong=$this->load->view('welcome_message',$data,true);
 if ( !write_file('./lianglongfile.html', $lianglong))
 {
  echo 'Unable to write the file';
 }
 else
 {
  echo 'File written!';
 }
}

更多關(guān)于CodeIgniter相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《codeigniter入門教程》、《CI(CodeIgniter)框架進(jìn)階教程》、《php優(yōu)秀開發(fā)框架總結(jié)》、《ThinkPHP入門教程》、《ThinkPHP常用方法總結(jié)》、《Zend FrameWork框架入門教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對大家基于CodeIgniter框架的PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論