svn: /phpdoc/en/trunk/reference/filter/functions/ filter-var.xml
| From: | Justin Martin | Date: | Sat, 21 Jan 2012 22:55:49 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/filter/functions/ filter-var.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-9484@lists.php.net to get a copy of this message | ||
frozenfire Sat, 21 Jan 2012 22:55:49 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=322551
Log:
Rewrote callback filter example. Closes bug #60769.
Bug: https://bugs.php.net/60769 (Open) typo in callback
example http://www.php.net/function.filter-var
Changed paths:
U phpdoc/en/trunk/reference/filter/functions/filter-var.xml
Modified: phpdoc/en/trunk/reference/filter/functions/filter-var.xml
===================================================================
--- phpdoc/en/trunk/reference/filter/functions/filter-var.xml 2012-01-21 22:45:45 UTC (rev 322550)
+++ phpdoc/en/trunk/reference/filter/functions/filter-var.xml 2012-01-21 22:55:49 UTC (rev 322551)
@@ -69,15 +69,17 @@
$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>