Jump to content

htmlspecialchars makes stuff safe?


LanceT

Recommended Posts

htmlspecialchars will replace certain characters into their ASCII form.

 

For example:

 

A < will be replaced as <

A > will be replaced as >

 

The safest way (in my opinion) would to use mysql_real_escape_string() before you enter information into your database.

If you are just looking to remove the html then strip_tags is the best option as you can allow certain tags aswell.

 

<?php

$var = "<script type='text/javascript'>window.location(http://www.ebay.co.uk)</script><b>Hi</b>";

$var = strip_tags($var, '<b>');

echo $var;

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.