//我来讲解下php安全之xss攻击实现+xss攻击防护
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="1.php" method="get">
<input type="text" name="data">
<input type="submit" value="提交">
</form>
</body>
</html>
<?php
$input=$_GET['data'];
$xss=htmlspecialchars((string)$input,ENT_QUOTES,'UTF-8');
echo $xss;
?>