# testing filter ext in RC1

- Thread: https://externals.io/message/24990
- Original archive: https://news-web.php.net/php.internals/24990
- Started by Kevin Waterson on 2006-07-26T18:01:23+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #24990 — Kevin Waterson — 2006-07-26T18:01:23+00:00

URL: https://externals.io/message/24990#24990

<?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."

---

## #24991 — Pierre — 2006-07-26T18:29:40+00:00

URL: https://externals.io/message/24990#24991 · In reply to: #24990

Hi,


> <?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

---

## #25041 — Pierre — 2006-07-28T16:43:38+00:00

URL: https://externals.io/message/24990#25041 · In reply to: #25040

> This one time, at band camp, Pierre <pierre.php@gmail.com> wrote:
>
>
> > […]
>
> 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

---

## #25040 — Kevin Waterson — 2006-07-28T17:10:29+00:00

URL: https://externals.io/message/24990#25040 · In reply to: #24991

This one time, at band camp, Pierre <pierre.php@gmail.com> wrote:


> > […]
> 
> 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."
