lime icon

Phosphorus and Lime

A Developer's Broadsheet

This blog has been deprecated. Please visit my new blog at klenwell.com/press.
PHP: strip_tags() test
A simple test for running strip_tags(). I wanted to test it with an allowed tags variable set using a heredoc:

$IR_CONFIG['form_pack']['allowed_tags'] = <<<TAGS
<div><span><pre><br><br />
<a><h1><h2><h3><h4><h5><h6><p>
<ul><li><ol>
<b><em><i><strong><u>
<table><tr><td><th>
<img><blockquote>
TAGS;


Code:

/* TEST
*******************************/

$string = <<<TEST
<div>
<script>this is a script</script>
<b>this is allowed</b>
<font>this is not allowed</font>
</div>
TEST;

$allowed_tags = $IR_CONFIG['form_pack']['allowed_tags'];
$clean = strip_tags($string, $allowed_tags);
echo htmlspecialchars($string) . '<br>';
echo htmlspecialchars($clean);

/******************************/