假设这段代码是在按下提交按钮后执行的,目的是为了清理:
<?php
$yourname = check_input(filter_input(INPUT_POST, 'yourname', FILTER_SANITIZE_STRING));
$email = check_input(filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL));
$likeit = check_input(filter_input(INPUT_POST, 'likeit', FILTER_SANITIZE_STRING));
$comments = check_input(filter_input(INPUT_POST, 'comments', FILTER_SANITIZE_STRING));
function check_input($data) {
$data = trim($data) . stripslashes($data) . htmlspecialchars($data);
return $data;
}
?>
考虑到正在应用 filter_input 函数,在这种情况下 check_input($data) 函数是多余的吗?