Php code for deleting html tags and html tags in strings

Source: Internet
Author: User
Php code for deleting html tags and html tags in strings
This article introduces how to delete html tags in php and the two examples of html tags in strings. For more information, see.

1. the example of deleting html tags uses the php string processing function strip_tags.

     "); // Clear the html format using the built-in functions of php. Keep the P tag $ str = preg_replace ("/\ t/", "", $ str); // use the regular expression to match the content to be replaced, such as space, line feed, and replace with null. $ Str = preg_replace ("/\ r \ n/", "", $ str); $ str = preg_replace ("/\ r/", "", $ str ); $ str = preg_replace ("/\ n/", "", $ str); $ str = preg_replace ("//", "", $ str ); $ str = preg_replace ("//", "", $ str); // matches the space return trim ($ str) in html ); // returns a string} // by>

2. the Function for deleting HTML tags in a string sometimes disables html tags when content is submitted on the page. the following functions can implement this function:

Articles you may be interested in: php: two ways to remove HTML tags php: remove excessive HTML tags php uses strip_tags to completely remove all html tags example of how php filters html tags using strip_tags) php: Three ways to delete html tags sharing: differences between strip_tags and htmlspecialchars for removing html tags in php: functions for deleting html tags in a string removing html tag code in the content extracting php code for html tags php code example for regular expression filtering of html tags, spaces, line breaks, etc. php removes html tags to obtain the code for the input plain text document strip_tagsphp to enable HTML tags to automatically complete closed functions. php implements html tag auto-completion code how to use thinkPHP Html template 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: 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.