Issues related to generating static files using Smarty

Source: Internet
Author: User
What is the problem of generating static files with Smarty? Require (& quot ;.. /inc/fuction. php & quot;); require (& quot ;.. /inc. php & quot;); require (& quot ;.. /inc/db. php & quot;); require & nbsp; (what is the problem of generating static files with Smarty?
Require ("../inc/fuction. php ");
Require ("../inc. php ");
Require ("../inc/db. php ");
Require ("../Smarty. class. php ");

$ Id = $ _ GET ['id'];
If (isset ($ id) & is_numeric ($ id ))
{
$ Db = new F2MysqlClass ($ dbhost, $ dbuser, $ dbpw, $ dbname );
$ SQL = "select * from news where id = '$ ID '";
$ Result = $ db-> fetchArray ($ db-> query ($ SQL ));
$ Tmp = new Smarty;

$ Tmp-> template_dir = "../smarty/templates ";
$ Tmp-> compile_dir = "../smarty/templates/templates_c ";
$ Tmp-> config_dir = "../smarty/templates/config ";
$ Tmp-> cache_dir = "../smarty/templates/cache ";

If (! Empty ($ result ))
{
$ Tmp-> assign (array (
"Title", htmlspecialchars ($ result ["title"]),
"Name", $ result ["author"]);
}
$ Tmp-> display ('index. tpl ');
$ This_my_f = ob_get_contents (); // key here
Ob_end_clean ();
$ Filename = "$id.html ";
If (tohtmlfile_cjjer ($ filename, $ this_my_f ))
Echo "generated successfully $ filename ";
Else
Echo "generate recognition ";

}

// Write the function of the file generation process
Function tohtmlfile_cjjer ($ file_cjjer_name, $ file_cjjer_content)
{
If (is_file ($ file_cjjer_name )){
@ Unlink ($ file_cjjer_name );
}
$ Cjjer_handle = fopen ($ file_cjjer_name, "w ");
If (! Is_writable ($ file_cjjer_name )){
Return false;
}
If (! Fwrite ($ cjjer_handle, $ file_cjjer_content )){
Return false;
}
Fclose ($ cjjer_handle); // Close the pointer
Return $ file_cjjer_name;
}

Files can be generated. But is the tag in the generated file not replaced? The labels are all blank. What's the problem?

------ Solution --------------------
Questions about assignment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.