Filter HTML-escapes special characters in PHP
Description
The following code shows how to filter HTML-escapes special characters.
Example
/*from w w w . j a v a2s . co m*/
<?php
$url="Is XML <smart> & funny?";
var_dump(filter_var($url,FILTER_SANITIZE_SPECIAL_CHARS));
/*
Possible flags:
FILTER_FLAG_STRIP_LOW - Strip characters with ASCII value below 32
FILTER_FLAG_STRIP_HIGH - Strip characters with ASCII value above 32
FILTER_FLAG_ENCODE_HIGH - Encode characters with ASCII value above 32
*/
?>
The code above generates the following result.