Rewrote callback filter example. Closes bug #60769.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@322551 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Justin Martin 2012-01-21 22:55:49 +00:00
parent 4f2bd63271
commit 5b22a7460f

View file

@ -69,15 +69,17 @@ $var = filter_var('oops', FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
$var = filter_var('oops', FILTER_VALIDATE_BOOLEAN,
array('flags' => FILTER_NULL_ON_FAILURE));
// callback filter
// callback validate filter
function foo($value)
{
$ret = new stdClass;
$ret->value = filter_var($value, FILTER_VALIDATE_BOOLEAN,
array('flags' => FILTER_NULL_ON_FAILURE));
return $ret;
// Expected format: Surname, GivenNames
list($surname, $givennames) = explode(", ", $value, 2);
if(
!(empty($surname) || empty($givennames))
&& (is_string($surname) && is_string($givennames))
) return $value; else return false;
}
$var = filter_var('yes', FILTER_CALLBACK, array('options' => 'foo'));
$var = filter_var('Doe, Jane Sue', FILTER_CALLBACK, array('options' => 'foo'));
?>
]]>
</programlisting>