<?php
$email = filter_input(INPUT_POST, 'name', FILTER_VALIDATE_EMAIL);
$age = filter_input(INPUT_POST, 'age', FILTER_VALIDATE_INT);
$url = filter_input(INPUT_COOKIE, 'url', FILTER_VALIDATE_URL);
$raw_msg = filter_input(INPUT_POST, 'msg', FILTER_UNSAFE_RAW);
$options = filter_input(INPUT_GET, 'options', FILTER_SANITIZE_SPECIAL_CHARS);
$data = filter_var($user_data, FILTER_SANITIZE_STRING);
?>
<table border="2" style="font-size:.9em; background:#fff;">
<?php
function test($data) {
return strtoupper($data);
}
$data = array("PHP","123","123abc<>()","O'Henry", "하퍼");
echo "<tr><th> </th><td>PHP</td><td>123</td><td>123abc<>()</td>";
echo "<td>O'Henry</td><td>하퍼</td></tr>\n";
foreach(filter_list() as $filter) {
$id = filter_id($filter);
switch($filter) {
case 'validate_regexp':
foreach($data as $k=>$v)
$result[$k] = filter_var($v,$id,array('options'=>array("regexp"=>'/^O.*/')));
break;
case 'callback':
foreach($data as $k=>$v)
$result[$k] = filter_var($v,$id,array("options"=>"test"));
break;
case 'validate_url':
foreach($data as $k=>$v)
$result[$k] = filter_var($v,$id,FILTER_FLAG_SCHEME_REQUIRED);
break;
default:
foreach($data as $k=>$v)
$result[$k] = filter_var($v,$id);
break;
}
echo "<tr><th align='left'>$filter</th>";
foreach($result as $v)
echo "<td>".htmlspecialchars($v)."</td>";
echo "</td></tr>\n";
}
?>
</table>