xref: /php-src/ext/filter/tests/011.phpt (revision bf94010b)
1--TEST--
2filter_input()
3--INI--
4precision=14
5--EXTENSIONS--
6filter
7--GET--
8a=<b>test</b>&b=http://example.com
9--POST--
10c=<p>string</p>&d=12345.7
11--FILE--
12<?php
13ini_set('html_errors', false);
14var_dump(filter_input(INPUT_GET, "b", FILTER_SANITIZE_URL));
15var_dump(filter_input(INPUT_GET, "a", FILTER_SANITIZE_SPECIAL_CHARS, array(1,2,3,4,5)));
16try {
17    filter_input(INPUT_GET, "b", FILTER_VALIDATE_FLOAT, new stdClass);
18} catch (TypeError $exception) {
19    echo $exception->getMessage() . "\n";
20}
21var_dump(filter_input(INPUT_POST, "d", FILTER_VALIDATE_FLOAT));
22var_dump(filter_input(INPUT_POST, "c", FILTER_SANITIZE_SPECIAL_CHARS));
23var_dump(filter_input(INPUT_POST, "d", FILTER_VALIDATE_INT));
24
25echo "Done\n";
26?>
27--EXPECT--
28string(18) "http://example.com"
29string(27) "&#60;b&#62;test&#60;/b&#62;"
30filter_input(): Argument #4 ($options) must be of type array|int, stdClass given
31float(12345.7)
32string(29) "&#60;p&#62;string&#60;/p&#62;"
33bool(false)
34Done
35