FAQ
<?php
$var=1234;
echo filter_data($var, FILTER_VALIDATE_INT);
?>

should the return values be either NULL or 1234?
well, it should return 1234
if var was abc1234 then it would return NULL, is that correct?

Kevin

--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."

Search Discussions

  • Pierre at Jul 26, 2006 at 6:29 pm
    Hi,
    On 7/26/06, Kevin Waterson wrote:
    <?php
    $var=1234;
    echo filter_data($var, FILTER_VALIDATE_INT);
    ?>

    should the return values be either NULL or 1234?
    well, it should return 1234 It does.
    if var was abc1234 then it would return NULL, is that correct?
    False if the value is not valid, null if the value does not exist (for
    example with input_get or input_get_args). In the case of filter_data,
    as you pass the variable, it will be either false or the correct
    value.

    Cheers,
    --Pierre
  • Kevin Waterson at Jul 28, 2006 at 4:36 pm

    This one time, at band camp, Pierre wrote:


    if var was abc1234 then it would return NULL, is that correct?
    False if the value is not valid, null if the value does not exist (for
    example with input_get or input_get_args). In the case of filter_data,
    as you pass the variable, it will be either false or the correct
    value.
    here it returns '0'

    Kevin
    --
    "Democracy is two wolves and a lamb voting on what to have for lunch.
    Liberty is a well-armed lamb contesting the vote."
  • Pierre at Jul 28, 2006 at 4:43 pm

    On 7/28/06, Kevin Waterson wrote:
    This one time, at band camp, Pierre wrote:

    if var was abc1234 then it would return NULL, is that correct?
    False if the value is not valid, null if the value does not exist (for
    example with input_get or input_get_args). In the case of filter_data,
    as you pass the variable, it will be either false or the correct
    value.
    here it returns '0'
    Please show me some code, "here" is not really helpful. For example:

    $ php -r '$var=1234; var_dump(filter_data($var, FILTER_VALIDATE_INT));'
    int(1234)

    $ php -r '$var=ab1234; var_dump(filter_data($var, FILTER_VALIDATE_INT));'
    bool(false)

    --Pierre
  • Jared Williams at Jul 28, 2006 at 7:12 pm
    Hi,
    An empty string returns 0.

    php -r "$var=''; var_dump(filter_data($var, FILTER_VALIDATE_INT));"
    int(0)

    Which maybe is what was intended, but imho still should return false.

    Jared
    -----Original Message-----
    From: Pierre
    Sent: 28 July 2006 17:44
    To: Kevin Waterson
    Cc: internals@lists.php.net
    Subject: Re: [PHP-DEV] testing filter ext in RC1
    On 7/28/06, Kevin Waterson wrote:
    This one time, at band camp, Pierre wrote:

    if var was abc1234 then it would return NULL, is that correct?
    False if the value is not valid, null if the value does
    not exist (for
    example with input_get or input_get_args). In the case of
    filter_data,
    as you pass the variable, it will be either false or the correct
    value.
    here it returns '0'
    Please show me some code, "here" is not really helpful. For example:

    $ php -r '$var=1234; var_dump(filter_data($var,
    FILTER_VALIDATE_INT));'
    int(1234)

    $ php -r '$var=ab1234; var_dump(filter_data($var,
    FILTER_VALIDATE_INT));'
    bool(false)

    --Pierre

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Jared Williams at Jul 29, 2006 at 11:33 am
    Hi,

    Also it does seem NUL char safe?

    php -r "$var='3'.chr(0).'foo'; var_dump(filter_data($var,
    FILTER_VALIDATE_INT));"
    int(3)


    Jared
    -----Original Message-----
    From: Pierre
    Sent: 28 July 2006 17:44
    To: Kevin Waterson
    Cc: internals@lists.php.net
    Subject: Re: [PHP-DEV] testing filter ext in RC1
    On 7/28/06, Kevin Waterson wrote:
    This one time, at band camp, Pierre wrote:

    if var was abc1234 then it would return NULL, is that correct?
    False if the value is not valid, null if the value does
    not exist (for
    example with input_get or input_get_args). In the case of
    filter_data,
    as you pass the variable, it will be either false or the correct
    value.
    here it returns '0'
    Please show me some code, "here" is not really helpful. For example:

    $ php -r '$var=1234; var_dump(filter_data($var,
    FILTER_VALIDATE_INT));'
    int(1234)

    $ php -r '$var=ab1234; var_dump(filter_data($var,
    FILTER_VALIDATE_INT));'
    bool(false)

    --Pierre

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Pierre at Jul 28, 2006 at 5:36 pm

    On 7/28/06, Jared Williams wrote:
    Hi,

    Also it does seem NUL char safe?

    php -r "$var='3'.chr(0).'foo'; var_dump(filter_data($var,
    FILTER_VALIDATE_INT));"
    int(3)
    Please report bugs in pecl.php.net/filter. It is hard to keep a trace
    of each post around here :)

    Thanks,
    --Pierre
  • Jared Williams at Jul 28, 2006 at 8:17 pm

    -----Original Message-----
    From: Pierre
    Sent: 28 July 2006 18:34
    To: Jared.Williams1@ntlworld.com
    Cc: Kevin Waterson; internals@lists.php.net
    Subject: Re: [PHP-DEV] testing filter ext in RC1
    On 7/28/06, Jared Williams wrote:
    Hi,

    Also it does seem NUL char safe?

    php -r "$var='3'.chr(0).'foo'; var_dump(filter_data($var,
    FILTER_VALIDATE_INT));"
    int(3)
    Please report bugs in pecl.php.net/filter. It is hard to keep a trace
    of each post around here :)
    Reported.

    http://pecl.php.net/bugs/bug.php?id=8315 - NUL
    http://pecl.php.net/bugs/bug.php?id=8316 - Empty string

    Jared

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedJul 26, '06 at 5:25p
activeJul 29, '06 at 11:33a
posts8
users3
websitephp.net

People

Translate

site design / logo © 2022 Grokbase