Template//This page is shown directly
Handle the value of a variable
$title = "This is the title";
$author = "This is the author";
$content = "This is content";
$times =date ("Y-year m-month D-Day");
Transfer into Template program module
Include ("Template.inc");
Create a template instance Mytemp
$mytemp = new Template ("."); This is the current directory for the template file, if the template file is filled in the template directory template
Set the Myfilehandle file handle to the template file that we want to call template.html
$mytemp->set_file ("Myfilehandle", "template.html");
Call the Set_var method of the template, set the variable title value in the template to $title,author for $author, etc.
$mytemp->set_var ("title", $title);
$mytemp->set_var ("author", $author);
$mytemp->set_var ("Times", $times);
$mytemp->set_var ("content", $content);
Invokes the parse method of the template, analyzes the template file that the Myfilehandle file handle points to, and replaces the corresponding variable
The complete HTML file content is saved in the string variable myoutput.
$mytemp->parse ("Myoutput", "Myfilehandle");
Print output result string variable myoutput value, direct output
$mytemp->p ("Myoutput");
?>
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