The example in this article describes how CodeIgniter generates a static page. Share to everyone for your reference, specific as follows:
Now let's develop how to let the CI framework generate static pages. The following direct code:
$this->output->get_output ();
Using this method, you can get the data you want to output, save it, and keep it used (when we do news type Web sites, we often need to generate static HTML files).
$string = $this->output->get_output ();
$this->load->helper (' file ');
Write_file ('./lianglong_codeigniter.html ', $string);
For example, the page we are going to output is the data that is going to load a view, then we
$this->load->view (' Welcome_lianglong);
Then join
$this->output->get_output ();
And the value to a variable such as $lianglong stored. Then use the Write_file auxiliary function in CI file to generate the file you want, as 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 written! ';
}
}
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 written! ';
}
}
More interested in CodeIgniter related content readers can view the site topics: "CodeIgniter Introductory Course", "CI (CodeIgniter) Framework Advanced Course", "PHP Excellent Development Framework Summary", "thinkphp Introductory Course", " Thinkphp Common Methods Summary, "Zend Framework Introduction Course", "PHP object-oriented Programming Introduction Course", "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design based on CodeIgniter framework.