1--TEST--
2Test stripslashes() function : usage variations - strings with newline and tab characters
3--FILE--
4<?php
5/*
6 * Test stripslashes() with strings containing newline and tab characters.
7*/
8
9echo "*** Testing stripslashes() : with strings containing newline and tab characters ***\n";
10
11// initialising  heredoc strings
12$heredoc_string_with_newline = <<<EOT
13This is line 1 \nof 'heredoc' string
14This is line 2 \nof "heredoc" string
15EOT;
16
17$heredoc_string_with_tab = <<<EOT
18This is line 1 \tof 'heredoc' string
19This is line 2 \tof "heredoc" string
20EOT;
21// initialising the string array
22
23$str_array = array(
24                    // string with newline character
25                    "\n",
26            "\\n",
27                    "Hello \nworld",
28                    "Hello \\nworld",
29                    '\n',
30            '\\n',
31                    'Hello \nworld',
32                    'Hello \\nworld',
33                    $heredoc_string_with_newline,
34
35                    // string with tab character
36            "\t",
37            "\\t",
38                    "Hello \tworld",
39                    "Hello \\tworld",
40            '\t',
41            '\\t',
42                    'Hello \tworld',
43                    'Hello \\tworld',
44                    $heredoc_string_with_tab
45                  );
46
47$count = 1;
48// looping to test for all strings in $str_array
49foreach( $str_array as $str )  {
50  echo "\n-- Iteration $count --\n";
51  var_dump( stripslashes($str) );
52  $count ++;
53}
54
55echo "Done\n";
56?>
57--EXPECT--
58*** Testing stripslashes() : with strings containing newline and tab characters ***
59
60-- Iteration 1 --
61string(1) "
62"
63
64-- Iteration 2 --
65string(1) "n"
66
67-- Iteration 3 --
68string(12) "Hello
69world"
70
71-- Iteration 4 --
72string(12) "Hello nworld"
73
74-- Iteration 5 --
75string(1) "n"
76
77-- Iteration 6 --
78string(1) "n"
79
80-- Iteration 7 --
81string(12) "Hello nworld"
82
83-- Iteration 8 --
84string(12) "Hello nworld"
85
86-- Iteration 9 --
87string(71) "This is line 1
88of 'heredoc' string
89This is line 2
90of "heredoc" string"
91
92-- Iteration 10 --
93string(1) "	"
94
95-- Iteration 11 --
96string(1) "t"
97
98-- Iteration 12 --
99string(12) "Hello 	world"
100
101-- Iteration 13 --
102string(12) "Hello tworld"
103
104-- Iteration 14 --
105string(1) "t"
106
107-- Iteration 15 --
108string(1) "t"
109
110-- Iteration 16 --
111string(12) "Hello tworld"
112
113-- Iteration 17 --
114string(12) "Hello tworld"
115
116-- Iteration 18 --
117string(71) "This is line 1 	of 'heredoc' string
118This is line 2 	of "heredoc" string"
119Done
120