note 64121 deleted from function.strip-tags by aharvey

From: 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('<','&lt',$string); $replaced_string = str_ireplace('>','&gt',$replaced_string); return $replaced_string; } echo block_tags('<b>HEY</b>'); //Returns &ltb&gtHEY&lt/b&gt ?>

« previous php.notes (#190911) next »