A method to avoid conflict between Smarty and CSS syntax _php instance

Source: Internet
Author: User

The examples in this article describe ways to avoid smarty conflicts with CSS syntax. Share to everyone for your reference. The specific analysis is as follows:

People who are familiar with CSS will soon find that there is a conflict between the syntax of Smarty and CSS, because both need to use braces {}. If you simply embed CSS markup into the HTML document header, you will cause an "unrecognized markup" error:

 
 

Don't worry, because we have 3 solutions.

First, use the link tag to extract style information from another file:

 
 

Second, use the smarty literal tag to surround style sheet information

These tags tell smarty not to parse any content within the tag:

 
 

Third, modify the default delimiter for Smarty

You can do this by setting the Center_delimiter and Center_delimiter properties:

<?php 
require ("Smarty.class.php"); 
$smarty =newsmarty; 
$smarty->left_delimiter= '; 
$smarty->right_delimiter= '; 
... 
? >

Although 3 solutions can solve the problem, the first one is probably the most convenient because it is a common practice to put CSS in a separate file. In addition, this solution does not require modifying the important default configuration (delimiters) of the smarty.

I hope this article will help you with your PHP program design.

Related Article

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.