xref: /PHP-8.0/ext/filter/tests/017.phpt (revision cc35cfd2)
1--TEST--
2filter_var() and FILTER_VALIDATE_REGEXP
3--SKIPIF--
4<?php if (!extension_loaded("filter")) die("skip"); ?>
5--FILE--
6<?php
7
8var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/.*/'))));
9var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/^b(.*)/'))));
10var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/^d(.*)/'))));
11var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/blah/'))));
12var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/\[/'))));
13try {
14    filter_var("data", FILTER_VALIDATE_REGEXP);
15} catch (ValueError $exception) {
16    echo $exception->getMessage() . "\n";
17}
18
19echo "Done\n";
20?>
21--EXPECT--
22string(4) "data"
23bool(false)
24string(4) "data"
25bool(false)
26bool(false)
27filter_var(): "regexp" option is missing
28Done
29