xref: /PHP-8.2/ext/filter/tests/027.phpt (revision 74859783)
1--TEST--
2filter_var() and FILTER_SANITIZE_ENCODED
3--EXTENSIONS--
4filter
5--FILE--
6<?php
7
8var_dump(filter_var("?><!@#$%^&*()}{~Qwertyuilfdsasdfgmnbvcxcvbn", FILTER_SANITIZE_ENCODED));
9var_dump(filter_var("<data&sons>", FILTER_SANITIZE_ENCODED));
10var_dump(filter_var("", FILTER_SANITIZE_ENCODED));
11
12var_dump(filter_var("?><!@#$%^&*()}{~Qwertyuilfdsasdfgmnbvcxcvbn", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_LOW));
13var_dump(filter_var("<data&sons>", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_LOW));
14var_dump(filter_var("", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_LOW));
15
16var_dump(filter_var("?><!@#$%^&*()}{~Qwertyuilfdsasdfgmnbvcxcvbn", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_HIGH));
17var_dump(filter_var("<data&sons>", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_HIGH));
18var_dump(filter_var("", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_HIGH));
19
20echo "Done\n";
21?>
22--EXPECT--
23string(75) "%3F%3E%3C%21%40%23%24%25%5E%26%2A%28%29%7D%7B%7EQwertyuilfdsasdfgmnbvcxcvbn"
24string(17) "%3Cdata%26sons%3E"
25string(0) ""
26string(75) "%3F%3E%3C%21%40%23%24%25%5E%26%2A%28%29%7D%7B%7EQwertyuilfdsasdfgmnbvcxcvbn"
27string(17) "%3Cdata%26sons%3E"
28string(0) ""
29string(75) "%3F%3E%3C%21%40%23%24%25%5E%26%2A%28%29%7D%7B%7EQwertyuilfdsasdfgmnbvcxcvbn"
30string(17) "%3Cdata%26sons%3E"
31string(0) ""
32Done
33