Php function example for deleting string HTML tags
- // Delete the html tag from the string
- // By bbs.it-home.org
- Function delete_htm ($ scr)
- {
- For ($ I = 0; $ I {
- If (substr ($ scr, $ I, 1) = "<")
- {
- While (substr ($ scr, $ I, 1 )! = ">") $ I ++;
- $ I ++;
- }
- $ Str = $ str. substr ($ scr, $ I, 1 );
- }
- Return ($ str );
- }
- ?>
How PHP removes HTML tags Method 1: directly retrieve the tag
- // Retrieve the br Mark
- Function strip ($ str)
- {
- $ Str = str_replace ("<br>", "", $ str );
- // $ Str = htmlspecialchars ($ str );
- Return strip_tags ($ str );
- }
- ?>
Method 2.PHP has a strip_tags function to easily remove HTML tags. Echo strip_tags ("HelloWorld"); // Remove HTML, XML, and PHP labels. You can also correctly remove non-standard HTML code: echo strip_tags ("\"> cftea "); // output cftea The strip_tags function removes HTML tags:
- $ Str = 'www
Dreamdu . Com ';
- Echo (htmlspecialchars ($ str )."
");
- Echo (strip_tags ($ str ));
- ?>
|