PHP filter例子

<?php
function convertSpace($str) {
return str_replace(' ', '_', $str);
}

$str = 'i am a great guy!';

echo filter_var($str, FILTER_CALLBACK, array('options'=>'convertSpace'));
echo filter_var($str, FILTER_CALLBACK, array('options'=>'strtoupper'));

//验证email
$email = 'xxx@dabaidu.com';
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo 'email is not valid';
} else {
echo 'email is valid';
}

上一篇:黄聪:OTP动态密码_Java代码实现


下一篇:判断图片的类型(图片是data类型 )