preg_match
函数以使帖子清理。### foreach ( $_POST as $key => $value) {
if (preg_match("~^[\r\n\s\w\d /<>:,.?@;-]+$~", $value)) {
echo 'Correct';
} else {
echo 'Incorrect';
}
}
preg_match
甚至一些字段为空。print_r
的POST,其中一些字段为空Array {
[email] => mi@mi2.com
[facebook] =>
[twitter] =>
[gplus] => glus
[firstname] => mi2
}