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!

你可能感兴趣的:(callback)