xref: /PHP-7.2/ext/filter/tests/033_run.inc (revision 2f334438)
1<?php
2if (function_exists('setlocale')) {
3	setlocale(LC_ALL, 'C');
4}
5
6function test($data) {
7  return strtoupper($data);
8}
9
10$data = array(
11	"PHP",
12	"1",
13	"foo@bar.com",
14	"http://a.b.c",
15	"1.2.3.4",
16	"123",
17	"123abc<>()",
18	"O'Henry",
19	"하퍼",
20	"aa:bb:cc:dd:ee:ff",
21);
22
23
24foreach(filter_list() as $filter) {
25	if($filter=="validate_regexp") {
26		foreach($data as $k=>$d) $result[$k] = filter_var($d,filter_id($filter),array("options"=>array("regexp"=>'/^O.*/')));
27	} else {
28		foreach($data as $k=>$d) $result[$k] = filter_var($d,filter_id($filter),array("options"=>"test"));
29	}
30	printf("%-20s",$filter);
31	printf("%-5s",$result[0]);
32	printf("%-3s",$result[1]);
33	printf("%-15s",$result[2]);
34	printf("%-20s",$result[3]);
35	printf("%-10s",$result[4]);
36	printf("%-5s",$result[5]);
37	printf("%-20s",$result[6]);
38	printf("%-15s",$result[7]);
39	printf("%-10s",$result[8]);
40	printf("%-10s\n",$result[9]);
41}
42?>
43