Home php教程 php手册 PHP快速模板技术

PHP快速模板技术

Jun 21, 2016 am 09:15 AM
template

模板

//此页是直接显示
//处理好变量的值
$title="这是标题";
$author="这是作者";
$content="这是内容";
$times=date("Y年m月d日");
 //调入模板程序模块
include("template.inc");
//创建一个模板实例mytemp
$mytemp = new Template("."); //此处.为模板文件当前目录,若模板文件在template目录中就填入template
//设置MyFileHandle文件句柄指向我们所要调用的模板文件template.html
$mytemp->set_file("MyFileHandle","template.html");
//调用模板的set_var方法,设置模板中的变量title值为$title,author为$author等
$mytemp->set_var("title", $title);
$mytemp->set_var("author", $author);
$mytemp->set_var("times", $times);
$mytemp->set_var("content", $content);
//调用模板的parse方法,对MyFileHandle文件句柄所指向的模板文件进行分析,替换其中相应变量
//并把替换结果即完整的HTML文件内容保存在字串变量MyOutput中
$mytemp->parse("MyOutput","MyFileHandle");
// 打印输出结果字串变量MyOutput的值 ,直接输出
$mytemp->p("MyOutput");
?>



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Data visualization through Golang's Template package Data visualization through Golang's Template package Jul 17, 2023 am 09:01 AM

Data visualization through Golang's Template package. With the advent of the big data era, data visualization has become one of the important means of information processing and analysis. Data visualization can present data in a concise and intuitive way, helping people better understand and analyze data. In Golang, we can use the Template package to implement data visualization functions. This article will introduce how to use Golang's Template package to achieve data visualization and provide code examples. GolangTem

Golang and the Template package: creating personalized user interfaces Golang and the Template package: creating personalized user interfaces Jul 18, 2023 am 10:27 AM

Golang and Template package: Create personalized user interface In modern software development, the user interface is often the most direct way for users to interact with the software. In order to provide a user interface that is easy to use and beautiful, developers need flexible tools to create and customize the user interface. In Golang, developers can use the Template package to achieve this goal. This article will introduce the basic usage of Golang and Template packages, and show how to create a personalized user interface through code examples.

How to solve 'undefined: template.Must' error in golang? How to solve 'undefined: template.Must' error in golang? Jun 24, 2023 pm 09:00 PM

Go language is an increasingly popular programming language with its concise syntax, efficient performance, and easy development. The Go language provides a powerful template engine - "text/template", but when using it, some people may encounter the "undefined:template.Must" error. The following is a method to solve this error. Import the correct package. When using the "text/template" template engine, you need to import "text/template

Golang and the Template package: building a powerful front-end development toolbox Golang and the Template package: building a powerful front-end development toolbox Jul 19, 2023 pm 02:43 PM

Golang and the Template package: Building a powerful front-end development toolbox In today's software development, front-end development is becoming more and more important throughout the project. In order to provide an elegant and reliable front-end development solution, we can use the Golang language and its built-in Template package. This article will introduce how to use Golang and the Template package to build a powerful front-end development toolbox. 1. Golang: Efficient and easy-to-use programming language Golang is a modern

Golang's Template package: developing high-performance web applications Golang's Template package: developing high-performance web applications Jul 17, 2023 pm 05:29 PM

Golang's Template package: developing high-performance web applications Introduction: In web development, the template engine is a very important component. It allows developers to combine dynamic data with static HTML templates to generate final web content. Golang's Template package provides an efficient and powerful way to work with templates. This article will introduce the basic usage of Golang's Template package, and show how to use it to develop high-performance web applications through some code examples.

Build a modern website using Golang's Template package Build a modern website using Golang's Template package Jul 19, 2023 am 09:22 AM

Use Golang's Template package to build modern websites. In recent years, with the rapid development of the Internet, more and more websites need to provide personalized content and interfaces. At the same time, Golang (also known as Go language) has become a popular choice for developing web applications due to its high performance and powerful concurrency capabilities. Golang's standard library provides a set of powerful and flexible template engines, namely the Template package. This article will introduce how to use Golang's Template package to build modern

How to use opsForValue of RedisTemplate How to use opsForValue of RedisTemplate Jun 03, 2023 am 08:55 AM

Use of the opsForValue() method in Redis 1. set(Kkey, Vvalue) adds a string type value, key is the key, and value is the value. redisTemplate.opsForValue().set("stringValue","bbb"); 2. get(Objectkey) gets the value corresponding to the key key. StringstringValue=redisTemplate.opsForValue().get("key")3. append(Kkey,St

Golang and Template package: quickly develop a convenient front-end interface Golang and Template package: quickly develop a convenient front-end interface Jul 17, 2023 pm 08:57 PM

Golang and Template package: quickly develop convenient front-end interface In modern Web development, the development of front-end interface is an important and indispensable link. The design of the front-end interface not only needs to be beautiful, but also needs to have a good user experience. However, the traditional front-end development process often requires a lot of time and effort. Fortunately, Golang provides the Template package, which is designed to help developers quickly build convenient front-end interfaces. Golang is an efficient, concise, concurrent, statically typed

See all articles