Table of Contents
Resolution of conflicts with CSS/JSON in PHP regular template engine, cssjson
php framework and template engine are a thing
php dynamically generates html tags and CSS issues
Home Backend Development PHP Tutorial Resolution of conflicts with CSS/JSON in PHP regular template engine, cssjson_PHP tutorial

Resolution of conflicts with CSS/JSON in PHP regular template engine, cssjson_PHP tutorial

Jul 13, 2016 am 10:20 AM
template engine

Resolution of conflicts with CSS/JSON in PHP regular template engine, cssjson

is mainly targeted at: Smarty/Dwoo

Reference: http://developer.51cto.com/art/201009/224929.htm

In fact, I didn’t pay much attention to template engines before and felt that there was no need to use them. But as I get older, my code obsession becomes more and more serious, and I start to encounter this problem.

There is a syntax conflict between Smarty and CSS/JS because both require the use of curly brackets {}. Although you can change Smarty's delimiter, it is not cost-effective for you to modify all related codes in an existing system.

1. Avoid simultaneous

Avoided by external references. The problem is that there is no avoiding it. So this situation is only suitable for a small number of simple situations.

2. Modify Smarty delimiter

2. Use Smarty’s literal tags to surround style sheet information

<span><</span><span>html</span><span>></span> 
<span><</span><span>head</span><span>></span> 
<span><</span><span>title</span><span>></span>{$title}<span></</span><span>title</span><span>></span><span> 
{literal}  
</span><span><</span><span>styletypestyletype</span><span>="text/css"</span><span>></span><span> 
p</span><span>{</span><span>  
margin</span><span>:</span><span>:2px  
</span><span>}</span>  
<span></</span><span>style</span><span>></span><span> 
{/literal}  
</span><span></</span><span>head</span><span>></span> 
Copy after login
<span><</span><span>script </span><span>type</span><span>="text/javascript"</span><span>></span>
      <span>function</span><span> goods_show(id){<br /><br /></span><span><!--</span><span>{literal}</span><span>--><br /><br /></span><span>art.dialog.open(url,{id:</span><span>'</span><span>select</span><span>'</span><span>,title:</span><span>'</span><span>的:</span><span>'</span><span>,width:</span><span>760</span><span>,height:</span><span>380</span><span>,padding: </span><span>'</span><span>10px</span><span>'</span><span>});<br /><br /></span><span><!--</span><span>{</span><span>/</span><span>literal}--></span>
<span>    }
</span><span></</span><span>script</span><span>></span>
Copy after login

The third type is undoubtedly green and environmentally friendly. Where conflicts are encountered, add literal to mark the package.

This solution is also effective for Dwoo engine.

php framework and template engine are a thing

You can understand the framework this way, just like the foundation of a building. No matter how the building is built, the method of building the foundation will always be similar.

In the process of our program development, you will find There must be many similar things and reusable things between each program. If you accumulate these similar things after each project, then these codes can be called libraries. When the libraries become more and more powerful, they may even be When the program structure can be reused, you can call it a framework.

The better domestic frameworks include thinkPHP, fleaPHP, foreign zendFramework and symfony. If you want to find a job in PHP, I suggest you learn zendFramework. It is recommended to use symfony for development.

Regarding the template engine, you can think of it as the painters in the construction team. They are professional painters. Those who build buildings do not care how to apply paint, and those who paint do not pay attention to the shape of the building. How to build it.

In fact, the main function of the template engine is to separate logic and display. Initially, it may be to allow programmers and artists to cooperate better. Since you are a beginner, I think you often use PHP If the code and HTML are written together, you can understand it yourself, but the artist may not be able to understand it. They may only be able to understand HTML and CSS. Furthermore, if the artist adds complex CSS or JS to the mixed code, you will not be able to understand it either. You will still not be able to understand it, which brings great difficulties to program development. That’s why there is a template engine, which completely separates logic and display. Programmers only need to focus on the logic, prepare the data at the end of the program, and then Pass it to the template, and the artist only needs to modify the template without considering the program logic. Template technology is often used in team development. I recommend you to learn smarty.

I don’t know if it has been explained thoroughly. If you don’t understand, it’s ok. Supplement.

php dynamically generates html tags and CSS issues

echo '

im create by php

'
?>

After compilation, what is the HTML structure? CSS is run on the client, so when you find that the style is wrong, you check the source file and save it as HTML to check and see if there is any difference. If you do it with AJAX and the source file does not have a corresponding structure, then open it FireBug copy the code to generate HTML and check it again!

In short, if you want to check CSS, please don’t stare at the program, put it in the client-side HTML environment and test it!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/864309.htmlTechArticleResolution of conflicts with CSS/JSON in PHP regular template engine, cssjson mainly targets: Smarty/Dwoo Reference: http ://developer.51cto.com/art/201009/224929.htm In fact, I didn’t pay much attention to it before...
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

What are the common template engines in PHP programming? What are the common template engines in PHP programming? Jun 12, 2023 am 09:50 AM

In recent years, the template engine in PHP programming has become an important part of PHP development, making it easier for programmers to develop and manage pages. This article will introduce common template engines in PHP programming. SmartySmarty is a commonly used PHP template engine. It supports a series of functions such as cached templates, plug-in modules and custom functions. Smarty's syntax is very flexible and can solve the problem of combining PHP variables with HTML tags, making the PHP language more suitable for templated design. Moreover, S

Learn to use the Golang template engine: A basic guide to using templates in Golang Learn to use the Golang template engine: A basic guide to using templates in Golang Jan 20, 2024 am 10:13 AM

Golang Template Engine Getting Started Guide: How to use templates in Golang, specific code examples are required Introduction: A template engine is a tool that can combine data and templates and generate documents in HTML, text or other formats. In Golang, we can use the built-in template package (html/template) to implement the functions of the template engine. This article will introduce in detail how to use the template engine in Golang and provide specific code examples. 1. The basic concept of template engine is to understand how to use it.

ThinkPHP6 template engine usage guide: Create an exquisite front-end interface ThinkPHP6 template engine usage guide: Create an exquisite front-end interface Aug 26, 2023 pm 11:09 PM

ThinkPHP6 template engine usage guide: Create an exquisite front-end interface Introduction: With the development of web applications, the design and development of front-end interfaces have become increasingly important. As a developer, we need to use a powerful template engine to help us create and manage front-end interfaces. ThinkPHP6's template engine is a powerful tool to meet this need. This article will introduce how to use the ThinkPHP6 template engine to create a beautiful front-end interface. Part 1: Install ThinkPHP6 template engine

How to use template engine Blade in Fat-Free framework? How to use template engine Blade in Fat-Free framework? Jun 03, 2023 pm 08:40 PM

Fat-Free Framework is a lightweight PHP framework designed to provide simple and flexible tools for building web applications. It contains many useful features such as routing, database access, caching, etc. In the Fat-Free framework, using the Blade template engine can help us manage and render templates more conveniently. Blade is the template engine in the Laravel framework, which provides powerful syntax and template inheritance capabilities. In this article I will demonstrate how to use Bl in Fat-Free framework

Template Engine in Go: A Complete Guide Template Engine in Go: A Complete Guide Jun 17, 2023 pm 12:55 PM

With the development of Internet technology, the demand for web applications is also increasing. Web developers often use template engines to generate dynamic web pages. This article will explore a new template engine: the Go language template engine. What is the Go language template engine? Go language is an advanced programming language developed by Google. Its syntax is concise and clear, making it easy to learn and use. The Go language template engine is a template system used to generate HTML templates in the Go language. The Go language template engine is called the "standard library".

Best Template Engine in PHP Best Template Engine in PHP May 24, 2023 pm 04:01 PM

PHP is a language widely used in web development. Whether you are developing a small website or a large system, PHP is very popular and convenient. In the PHP development process, we need to separate the logic and data layers, which requires the use of a template engine. The template engine can be simply understood as merging data and template files to generate the final HTML file. In this article, we will introduce some of the best template engines available in PHP. SmartySmarty is one of the most popular template engines in PHP,

A preliminary study on the template engine Smarty in PHP A preliminary study on the template engine Smarty in PHP May 11, 2023 pm 05:15 PM

Nowadays, website development is inseparable from an important component-template engine. A template engine refers to a tool that combines page templates and data to generate HTML code with a specific format. In various website development frameworks, the template engine is an essential component, because the template engine can greatly reduce the duplication of code and improve the dynamics of the page. One of the most common and popular template engines is Smarty. Smarty is a DSL (DomainSpecif

How to use layout files of template engine Blade in Laravel framework? How to use layout files of template engine Blade in Laravel framework? Jun 03, 2023 pm 04:21 PM

In the Laravel framework, using the Blade template engine can help us write view files more conveniently and quickly. The layout file feature allows us to easily reuse view files and improve coding efficiency. This article will introduce how to use Blade's layout file in the Laravel framework and give specific implementation steps. First, we need to understand what a layout file is in the Blade template engine. Simply put, a layout file is a special view file in which the

See all articles