【发布时间】:2015-01-28 00:50:10
【问题描述】:
我有一个名为$ID 的字符串从另一个页面进入并点击base64_decode($enc); 并想检查它是否有任何奇怪的字符。 $ID 解密后只能包含字母、数字、下划线和破折号。
我看过preg_replace('/[\x80-\xFF]/', '', $string);,它去掉了一些奇怪的字符——这很有帮助——但我有时仍然可以看到@符号和括号之类的东西仍然存在。
有没有办法降低 ascii 测试?或者,除了字母、数字、下划线和破折号之外,我还能如何删除所有内容?
任何能帮我指出正确方向的帮助都很棒,谢谢!
$enc = $_GET["key"];
$ID= base64_decode($enc);
if (empty($enc)) { echo "key is empty"; } else {
echo "string ok<br>";
$check = preg_replace('/[\x80-\xFF]/', '', $ID);
echo $check;
// i can see this step is helping cut junk out, do more tests from here
}
【问题讨论】:
标签: php string preg-replace ascii asciiencoding