狮子座男

导航

PHP filter 函数FILTER_CALLBACK 过滤数据

<?php
function convertSpace($string)
 {
 return str_replace(" ", "_", $string);
 }

$string = "Peter is a great guy!";

echo filter_var($string, FILTER_CALLBACK,array("options"=>"convertSpace"));
echo '<br>';
echo filter_var($string,FILTER_CALLBACK,array("options"=>"strtoupper"));

?>

Peter_is_a_great_guy!
PETER IS A GREAT GUY!

posted on 2014-09-03 16:44  狮子座男  阅读(377)  评论(0编辑  收藏  举报