1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
--TEST--
Test strip_tags() function : usage variations - invalid values for 'str' and valid 'allowable_tags'
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])
* Description: Strips HTML and PHP tags from a string
* Source code: ext/standard/string.c
*/
/*
* testing functionality of strip_tags() by giving invalid values for $str and valid values for $allowable_tags argument
*/
echo "*** Testing strip_tags() : usage variations ***\n";
// unexpected values for $string
$strings = array (
"<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>",
'<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>',
"<%?php hello\t world?%>",
'<%?php hello\t world?%>',
"<<htmL>>hello<</htmL>>",
'<<htmL>>hello<</htmL>>',
"<a.>HtMl text</.a>",
'<a.>HtMl text</.a>',
"<nnn>I am not a valid html text</nnn>",
'<nnn>I am not a valid html text</nnn>',
"<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>",
'<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>',
);
//valid html and php tags
$quotes = "<p><a><?php<html>";
//loop through the various elements of strings array to test strip_tags() functionality
$iterator = 1;
foreach($strings as $string_value)
{
echo "-- Iteration $iterator --\n";
var_dump( strip_tags($string_value, $quotes) );
$iterator++;
}
echo "Done";
?>
--EXPECT--
*** Testing strip_tags() : usage variations ***
-- Iteration 1 --
string(32) "hello world... strip_tags_test"
-- Iteration 2 --
string(34) "hello \t\tworld... strip_tags_test"
-- Iteration 3 --
string(0) ""
-- Iteration 4 --
string(0) ""
-- Iteration 5 --
string(18) "<htmL>hello</htmL>"
-- Iteration 6 --
string(18) "<htmL>hello</htmL>"
-- Iteration 7 --
string(9) "HtMl text"
-- Iteration 8 --
string(9) "HtMl text"
-- Iteration 9 --
string(26) "I am not a valid html text"
-- Iteration 10 --
string(26) "I am not a valid html text"
-- Iteration 11 --
string(62) "I am a quoted (") string with special chars like $,\!,\@,\%,\&"
-- Iteration 12 --
string(64) "I am a quoted (\") string with special chars like \$,\!,\@,\%,\&"
Done
|