filter_callback
function myfilter($val)
{
if(in_array($val, ['one','two','three'])){
return false;
}else
return $val;
}
function test($str)
{
$opti
$rs=filter_var($str,filter_callback,$options);
var_dump($rs);
echo '<br>';
}
test('one');
test('aaa');
test(['bbb','two','123']);结果:
bool(false)
string(3) "aaa"
array(3) { [0]=> string(3) "bbb" [1]=> bool(false) [2]=> string(3) "123" } FILTER_VALIDATE_INT
function test($num)
{
$opti
$rs=filter_var($num,FILTER_VALIDATE_INT,$options);
var_dump($rs);
echo '<br>';
}
test(99);
test(120);
test(250);int(130) int(120) int(130)
以上就介绍了filter_var php,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号