Annotation of embedaddon/php/ext/standard/tests/strings/htmlspecialchars_decode_variation6.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test htmlspecialchars_decode() function : usage variations - binary safe
3: --FILE--
4: <?php
5: /* Prototype : string htmlspecialchars_decode(string $string [, int $quote_style])
6: * Description: Convert special HTML entities back to characters
7: * Source code: ext/standard/html.c
8: */
9:
10: /*
11: * testing whether htmlspecialchars_decode() is binary safe or not
12: */
13:
14: echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
15:
16: //various string inputs
17: $strings = array (
18: "\tHello \$world ".chr(0)."\&!)The big brown fox jumped over the\t\f lazy dog\v\n",
19: "\tHello \"world\"\t\v \0 This is a valid\t string",
20: "This converts\t decimal to \$string".decbin(65)."Hello world",
21: b"This is a binary\t \v\fstring"
22: );
23:
24: //loop through the strings array to check if htmlspecialchars_decode() is binary safe
25: $iterator = 1;
26: foreach($strings as $value) {
27: echo "-- Iteration $iterator --\n";
28: if ($iterator < 4) {
29: var_dump( htmlspecialchars_decode($value) );
30: } else {
31: var_dump( bin2hex(htmlspecialchars_decode($value)));
32: }
33:
34: $iterator++;
35: }
36:
37: echo "Done";
38: ?>
39: --EXPECTF--
40: *** Testing htmlspecialchars_decode() : usage variations ***
41: -- Iteration 1 --
42: string(65) " Hello $world \&!)The big brown fox jumped over the lazy dog
43: "
44: -- Iteration 2 --
45: string(42) " Hello "world" This is a valid string"
46: -- Iteration 3 --
47: string(51) "This converts decimal to $string1000001Hello world"
48: -- Iteration 4 --
49: string(52) "5468697320697320612062696e61727909200b0c737472696e67"
50: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>