Reputation: 15
im trying to use Strip_tags and nl2br on the content which i echo out from the database. However, strip_tags doesnt work but nl2br does. What i want to do is to remove all the html or php tags inside the content if it is possible. By the way im using php 5.2.17 . Please help.
Output
Content:
<p><span style="color: #00ff00;">This is a new Page<br /><br />This is a new sentence</span></p>
Content
Content:<br />
<div class="view-content">
<?php echo
strip_tags(htmlentities($current_page["content"])); ?>
</div>
Upvotes: 0
Views: 826
Reputation: 781058
You should do:
echo htmlentities(strip_tags($current_page["content"]));
Since you were calling htmlentities
first, the tags couldn't be recognized in the content because the <
and >
characters were replaced with <
and >
.
Upvotes: 0
Reputation: 19309
If you're using strip_tags
you don't need htmlentites
. You output is being converted to entites first and so you don't have any tags to strip. Change it to:
<?php echo strip_tags($current_page["content"]); ?>
Upvotes: 2