CodeIgniter generates a static page method, CodeIgniter generates a static
The examples in this article describe how CodeIgniter generates static pages. Share to everyone for your reference, as follows:
Now let's develop how to get the CI framework to generate static pages. The following direct code:
$this->output->get_output ();
Using this method, you can get the data that will be output and save it and keep it (we often need to generate a static HTML file when we do the news type site).
$string = $this->output->get_output (); $this->load->helper (' file '); Write_file ('./lianglong_ Codeigniter.html ', $string);
For example, the page we want to output is the data to load a view, so we
$this->load->view (' Welcome_lianglong);
Then join
$this->output->get_output ();
and store the value to a variable such as $lianglong. Then use the Write_file helper function in the CI file to generate the file you want, as in the following example
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 Writt En! '; }}
Or:
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 Writt En! '; }}
More interested in CodeIgniter related content readers can view this site topic: "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "PHP Excellent Development Framework Summary", "thinkphp Getting Started", " Summary of common methods of thinkphp, "Introduction to Zend Framework Frame", "Introduction to PHP Object-oriented Programming", "Introduction to Php+mysql Database Operation" and "PHP common database Operation Skills Summary"
It is hoped that this article is helpful to the PHP program design based on CodeIgniter framework.
http://www.bkjia.com/PHPjc/1127866.html www.bkjia.com true http://www.bkjia.com/PHPjc/1127866.html techarticle CodeIgniter Generate static page methods, CodeIgniter generate static This article describes the CodeIgniter method of generating a static page. Share to everyone for your reference, as follows: Now we ...