Home > php教程 > php手册 > body text

PHP filter例子

WBOY
Release: 2016-06-06 19:43:24
Original
1002 people have browsed it

?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'='strtouppe

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';
}

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 Recommendations
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!