summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/strip_tags_variation5.phpt
blob: 20b569390502656167ab0ce3e912d7dbbd38c1a2 (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
--TEST--
Test strip_tags() function : usage variations - heredoc strings
--INI--
short_open_tag = on
--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 heredoc strings as values for $str argument
*/

echo "*** Testing strip_tags() : usage variations ***\n";

// null here doc string
$null_string = <<<EOT
EOT;

// heredoc string with blank line
$blank_line = <<<EOT

EOT;

// here doc with multiline string
$multiline_string = <<<EOT
<html>hello world</html>
<p>13 &lt; 25</p>
<?php 1111 &amp; 0000 = 0000 ?>
<b>This is a double quoted string</b>
EOT;

// here doc with different whitespaces
$diff_whitespaces = <<<EOT
<html>hello\r world\t
1111\t\t != 2222\v\v</html>
<? heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces ?>
EOT;

// here doc with numeric values
$numeric_string = <<<EOT
<html>11 < 12. 123 >22</html>
<p>string</p> 1111\t <b>0000\t = 0000\n</b>
EOT;

// heredoc with quote chars & slash
$quote_char_string = <<<EOT
<html>This's a string with quotes:</html>
"strings in double quote";
'strings in single quote';
<html>this\line is single quoted /with\slashes </html>
EOT;

$res_heredoc_strings = array(
  //heredoc strings
  $null_string,
  $blank_line,
  $multiline_string,
  $diff_whitespaces,
  $numeric_string,
  $quote_char_string
);

// initialize the second argument
$quotes = "<html><a><?php";

// loop through $res_heredoc_strings element and check the working on strip_tags()
$count = 1;
for($index =0; $index < count($res_heredoc_strings); $index ++) {
  echo "-- Iteration $count --\n";
  var_dump( strip_tags($res_heredoc_strings[$index], $quotes) );
  $count++;
}

echo "Done\n";
?>
--EXPECTF--
*** Testing strip_tags() : usage variations ***
-- Iteration 1 --
string(0) ""
-- Iteration 2 --
string(0) ""
-- Iteration 3 --
string(67) "<html>hello world</html>
13 &lt; 25

This is a double quoted string"
-- Iteration 4 --
string(44) "<html>hello
 world	
1111		 != 2222</html>
"
-- Iteration 5 --
string(56) "<html>11 < 12. 123 >22</html>
string 1111	 0000	 = 0000
"
-- Iteration 6 --
string(150) "<html>This's a string with quotes:</html>
"strings in double quote";
'strings in single quote';
<html>this\line is single quoted /with\slashes </html>"
Done