In smarty, use strip_tags to filter html tags and truncate to intercept articles. tutorial _ PHP

Source: Internet
Author: User
In smarty, use strip_tags to filter html tags and truncate to intercept articles. The strip_tags () function removes tags from HTML, XML, and PHP. Copy the code as follows :? Phpechostrip_tags ("Hellobworld! B ");? In smarty, you can use the strip_tags function to remove tags of html, XML, and PHP.

The code is as follows:


World!");?>


In smarty, you can use strip_tags to remove html tags, including any content between <>.

For example:

Index. php:

The code is as follows:


$ Smarty = new Smarty;
$ Smarty-> assign ('articletitle', "Blind Woman Gets New Kidney from Dad she hasn' t Seen inYears.");
$ Smarty-> display ('index. tpl ');


Index. tpl:

The code is as follows:


{$ ArticleTitle}
{$ ArticleTitle | strip_tags}


Output result:

The code is as follows:


Blind Woman Gets New Kidney from Dad she Hasn't Seen inYears.
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.


Article interception:

The code is as follows:


{$ Article. content | truncate: 35 :"..." : True}

The http://www.bkjia.com/PHPjc/322495.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/322495.htmlTechArticlestrip_tags () function removes HTML, XML, and PHP labels. The code is as follows :? Php echo strip_tags ("Hello bworld! /B ");? In smarty, you can use strip_tags to remove html tags...

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.