xref: /PHP-7.3/ext/filter/tests/037.phpt (revision 782352c5)
1--TEST--
2GET and data callback tests
3--SKIPIF--
4<?php if (!extension_loaded("filter")) die("skip"); ?>
5--GET--
6a=1&b=2
7--FILE--
8<?php
9function myfunc($val) {
10	return $val . '_callback';
11}
12echo filter_input(INPUT_GET, 'a', FILTER_CALLBACK, array("options"=>'myfunc'));
13echo "\n";
14echo filter_input(INPUT_GET, 'b', FILTER_VALIDATE_INT);
15echo "\n";
16$data = "data";
17
18echo filter_var($data, FILTER_CALLBACK, array("options"=>'myfunc'));
19echo "\n";
20
21$res = filter_input_array(INPUT_GET, array(
22				'a' => array(
23					'filter' => FILTER_CALLBACK,
24					'options' => 'myfunc'
25					),
26				'b' => FILTER_VALIDATE_INT
27		)
28	);
29
30var_dump($res);
31?>
32--EXPECT--
331_callback
342
35data_callback
36array(2) {
37  ["a"]=>
38  string(10) "1_callback"
39  ["b"]=>
40  int(2)
41}
42