xref: /PHP-7.3/ext/filter/tests/059.phpt (revision 529baa9a)
1--TEST--
2filter_var() and FILTER_SANITIZE_ADD_SLASHES
3--SKIPIF--
4<?php if (!extension_loaded("filter")) die("skip"); ?>
5--FILE--
6<?php
7
8function filter_test_compare($input) {
9    return filter_var($input, FILTER_SANITIZE_ADD_SLASHES) === filter_var($input, FILTER_SANITIZE_MAGIC_QUOTES);
10}
11
12var_dump(filter_var("test'asd'asd'' asd\'\"asdfasdf", FILTER_SANITIZE_ADD_SLASHES));
13var_dump(filter_var("'", FILTER_SANITIZE_ADD_SLASHES));
14var_dump(filter_var("", FILTER_SANITIZE_ADD_SLASHES));
15var_dump(filter_var(-1, FILTER_SANITIZE_ADD_SLASHES));
16
17var_dump(filter_test_compare("test'asd'asd'' asd\'\"asdfasdf"));
18var_dump(filter_test_compare("''"));
19var_dump(filter_test_compare(''));
20var_dump(filter_test_compare(-1));
21
22echo "Done\n";
23?>
24--EXPECT--
25string(36) "test\'asd\'asd\'\' asd\\\'\"asdfasdf"
26string(2) "\'"
27string(0) ""
28string(2) "-1"
29bool(true)
30bool(true)
31bool(true)
32bool(true)
33Done
34