Re: svn: /phpdoc/en/trunk/reference/filter/functions/ filter-var.xml

From: Date: Sun, 22 Jan 2012 00:01:34 +0000
Subject: Re: svn: /phpdoc/en/trunk/reference/filter/functions/ filter-var.xml
References: 1  Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-9487@lists.php.net to get a copy of this message
On 21 January 2012 22:55, Justin Martin <frozenfire@php.net> wrote: > 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; Urgh, that is ugly. Could you tidy the if statement up? (Remember: PEAR coding standards.) And perhaps change the code to not issue an E_NOTICE when there is no ", " in the value? >  } > -$var = filter_var('yes', FILTER_CALLBACK, array('options' => > 'foo')); > +$var = filter_var('Doe, Jane Sue', FILTER_CALLBACK, array('options' => > 'foo')); >  ?> >         ]]> >        </programlisting> > > > -- > PHP Documentation Commits Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.doc.cvs (#9487) next »