testing filter ext in RC1

php.internals

Kevin Waterson

20 years ago
<?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."

Pierre Joye

20 years ago
Hi, On 7/26/06, Kevin Waterson <kevin@oceania.net> 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

20 years ago
This one time, at band camp, Pierre <pierre.php@gmail.com> 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 Joye

20 years ago
On 7/28/06, Kevin Waterson <kevin@oceania.net> wrote:
> This one time, at band camp, Pierre <pierre.php@gmail.com> 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

20 years ago
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

Pierre Joye

20 years ago
On 7/28/06, Jared Williams <jared.williams1@ntlworld.com> 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

20 years ago
> -----Original Message----- > From: Pierre [mailto:pierre.php@gmail.com] > 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 <jared.williams1@ntlworld.com> 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

Jared Williams

20 years ago
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