note 85940 modified in function.strip-tags by danbrown

From: Date: Thu, 25 Sep 2008 16:28:56 +0000
Subject: note 85940 modified in function.strip-tags by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-144705@lists.php.net to get a copy of this message
I was looking for a simple way to ban html from review posts, and the like. I have seen a few classes to do it. This line, while it doesn't strip the post, effectively blocks people from posting html in review and other forms. <?php if (strlen(strip_tags($review)) < strlen($review)) { return false; } ?> If you want to further get by the tricksters that use & for html links, include this: <?php if (strlen(strip_tags($review)) < strlen($review)) { return false; } elseif ( strpos($review, "&") !== false) { return 5; } ?> I hope this helps someone out! --was-- I was looking for a simple way to ban html from review posts, and the like. I have seen a few classes to do it. This line, while it doesn't strip the post, effectively blocks people from posting html in review and other forms. if (strlen(strip_tags($review)) < strlen($review)) { return false; } If you want to further get by the tricksters that use & for html links, include this: if (strlen(strip_tags($review)) < strlen($review)) { return false; } elseif ( strpos($review, "&") !== false) { return 5; } I hope this helps someone out! http://php.net/manual/en/function.strip-tags.php

« previous php.notes (#144705) next »