note 64121 deleted from function.strip-tags by aharvey
| From: | aharvey@php.net | Date: | Thu, 20 Sep 2012 11:55:37 +0000 |
| Subject: | note 64121 deleted from function.strip-tags by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190911@lists.php.net to get a copy of this message | ||
Note Submitter: JeremysFilms.com
----
A simple little function for blocking tags by replacing the '<' and '>'
characters with their HTML entities. Good for simple posting systems that you don't want to
have a chance of stripping non-HTML tags, or just want everything to show literally without any
security issues:
<?php
function block_tags($string){
$replaced_string = str_ireplace('<','<',$string);
$replaced_string = str_ireplace('>','>',$replaced_string);
return $replaced_string;
}
echo block_tags('<b>HEY</b>'); //Returns <b>HEY</b>
?>