filter_var php

WBOY
Release: 2016-08-08 09:22:16
Original
1104 people have browsed it

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']);
Copy after login

Results:

bool(false) 
string(3) "aaa" 
array(3) { [0]=> string(3) "bbb" [1]=> bool(false) [2]=> string(3) "123" } 
Copy after login

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);
Copy after login

Results:
int(130) 
int(120) 
int(130) 
Copy after login

The above introduces filter_var php, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!