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