Solve CSS/JSON conflicts in the regular PHP template engine. cssjson_PHP tutorial

Source: Internet
Author: User
Solution to conflicts with CSSJSON in the common PHP template engine, cssjson. Solve the css json conflict in the conventional PHP template engine. CSSJSON is mainly targeted at Objects: SmartyDwoo reference: .51cto.comart201009224929.htm. In fact, css json does not focus much on solving CSS/JSON conflicts in the conventional PHP template engine.

Target objects: Smarty/Dwoo

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

In fact, we didn't pay much attention to the template engine in the past and thought it was unnecessary to use it. But with the increase of age, code cleansing becomes more and more serious, and this problem begins to emerge.

There is a conflict between the syntax of Smarty and CSS/JS, because both must use braces {}. Although you can change the definition of Smarty, it is not cost-effective to modify all the relevant code in an existing system.

1.Avoid simultaneous appearance

Avoid using external references. The problem is that it is unavoidable. Therefore, this situation is only suitable for a few simple cases.

2. modify the Smarty identifier

2.Use the literal tag of Smarty to enclose the style sheet information

  {$title} {literal}  
 
   p{  margin::2px  }   {/literal}   
 

The third type is undoubtedly Green. in the event of a conflict, add literal label packages.

This solution is equally effective for the Dwoo engine.


Php framework and template engine are a bit of a problem

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

During program development, you will find that there are many similar and reusable items between each program, if you accumulate these similar things after each project, the code can be called a library. when the library becomes more and more powerful and even the program structure can be reused, you can call the framework.

Better frameworks in China include thinkPHP, fleaPHP, zendFramework and symfony. if you want to find a job by using php, you are advised to learn zendFramework. if you are a developer, you are advised to use symfony.

You can understand the template engine as a paint painter in the construction team. they paint professionally, but they do not need to paint the building, or paint the building.

In fact, the main role of the template engine is to separate the logic and display. it may initially be to allow programmers and the artist to better cooperate, I think you often write php code and html code together. you can understand it yourself, but artists may not necessarily understand it. they may only understand html and css, furthermore, if the artist adds complex css or js to the mixed code, you will not understand it, which brings great difficulties to program development. therefore, the template engine separates the logic from the display. the programmer only needs to focus on the logic, prepare the data at the end of the program, and then pass the data to the template, however, as long as the artist modifies the template, he does not need to consider the program logic. the template technology is often used in team development. we recommend that you learn smarty here.

I do not know whether it is transparent or not.

Php dynamic generation of html tags and CSS issues

Echo'

Im create by php </p>'
?>

After compilation, what is the HTML structure? CSS is run on the client, so when you find that the style is incorrect, you can view the source file and save it as HTML to check what is different. if you do it with AJAX, if the source file does not have a corresponding structure, open FireBug to generate HTML and check again!

In short, do not stare at the program to check CSS. put it in the HTML environment of the client and test it!

Objects mainly for objects: Smarty/Dwoo reference: http://developer.51cto.com/art/201009/224929.htm is actually not concerned about the past...

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.