Home > php教程 > php手册 > 自定义函数过滤字符串

自定义函数过滤字符串

WBOY
Release: 2016-06-06 19:33:25
Original
1068 people have browsed it

4,5行不懂求解释 无 ?phpfunction str($str){$array = array("1","2","3","4","5","6");$repstr = implode($array);if(preg_match("/$str/",$repstr)){echo "scriptalert('您使用了禁用词语,请重新填写');location.href='16.php'/script";}else{echo "内容为

4,5行 不懂 求解释
<?php
	function str($str){
		$array = array("1","2","3","4","5","6");
		$repstr = implode($array);
		if(preg_match("/$str/",$repstr)){
			echo "<script>alert('您使用了禁用词语,请重新填写');location.href='16.php'</script>";
		}else{
			echo "内容为:".$str;
		}
	}
	if(!empty($_POST['sub'])){
		str($_POST['te']);
	}
?>
<html>
<head>
<title>过滤字符串</title>
<meta  charset=utf-8">
</head>
<body>
<form action="" method="post">
			<b style="float:left">内容:</b><textarea cols="18" rows="2" name="te"></textarea>
			<p><center><input type="submit" name="sub" value="提交"></center></p>
</form>
</body>
</html>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template