2
Test stripslashes() function : usage variations - with magic_quotes_sybase directive ON
5
/* Prototype : string stripslashes ( string $str )
6
* Description: Returns an un-quoted string
7
* Source code: ext/standard/string.c
11
* Test stripslashes() with PHP directive magic_quotes_sybase set ON
14
echo "*** Testing stripslashes() : with php directive magic_quotes_sybase set ON ***\n";
16
// setting ON the php directive magic_quotes_sybase
17
ini_set("magic_quotes_sybase", "1");
19
// initialising a heredoc string
20
$heredoc_string = <<<EOT
21
This is line 1 of 'heredoc' string
22
This is line 2 of "heredoc" string
25
$heredoc_null_string =<<<EOT
28
// initialising the string array
30
// string without any characters that can be backslashed
33
// string with single quotes
35
"don't disturb u'r neighbours",
36
"don't disturb u'r neighbours''",
41
// string with double quotes
42
'he said, "he will be on leave"',
43
'he said, ""he will be on leave"',
50
// string with backslash characters
51
'Is your name Ram\Krishna?',
52
'c:\php\testcase\stripslashes',
55
// string with nul characters
56
'hello'.chr(0).'world',
57
chr(0).'hello'.chr(0),
58
chr(0).chr(0).'hello',
63
"\\\"'0.0.0.0'".chr(0),
65
'"c:\php\"'.chr(0)."'",
66
'"hello"'."'world'".chr(0).'//',
68
// string with hexadecimal number
80
// looping to test for all strings in $str_array
81
foreach( $str_array as $str ) {
82
echo "\n-- Iteration $count --\n";
83
$str_addslashes = addslashes($str);
84
var_dump("The string after addslashes is:", $str_addslashes);
85
$str_stripslashes = stripslashes($str_addslashes);
86
var_dump("The string after stripslashes is:", $str_stripslashes);
87
if( strcmp($str, $str_stripslashes) != 0 )
88
echo "\nOriginal string and string from stripslashes() donot match\n";
95
*** Testing stripslashes() : with php directive magic_quotes_sybase set ON ***
97
string(31) "The string after addslashes is:"
98
string(11) "Hello world"
99
string(33) "The string after stripslashes is:"
100
string(11) "Hello world"
102
string(31) "The string after addslashes is:"
103
string(18) "how''re you doing?"
104
string(33) "The string after stripslashes is:"
105
string(17) "how're you doing?"
107
string(31) "The string after addslashes is:"
108
string(30) "don''t disturb u''r neighbours"
109
string(33) "The string after stripslashes is:"
110
string(28) "don't disturb u'r neighbours"
112
string(31) "The string after addslashes is:"
113
string(34) "don''t disturb u''r neighbours''''"
114
string(33) "The string after stripslashes is:"
115
string(30) "don't disturb u'r neighbours''"
117
string(31) "The string after addslashes is:"
119
string(33) "The string after stripslashes is:"
122
string(31) "The string after addslashes is:"
124
string(33) "The string after stripslashes is:"
127
string(31) "The string after addslashes is:"
129
string(33) "The string after stripslashes is:"
132
string(31) "The string after addslashes is:"
133
string(30) "he said, "he will be on leave""
134
string(33) "The string after stripslashes is:"
135
string(30) "he said, "he will be on leave""
137
string(31) "The string after addslashes is:"
138
string(31) "he said, ""he will be on leave""
139
string(33) "The string after stripslashes is:"
140
string(31) "he said, ""he will be on leave""
142
string(31) "The string after addslashes is:"
143
string(9) """"PHP""""
144
string(33) "The string after stripslashes is:"
145
string(9) """"PHP""""
147
string(31) "The string after addslashes is:"
149
string(33) "The string after stripslashes is:"
152
string(31) "The string after addslashes is:"
154
string(33) "The string after stripslashes is:"
157
string(31) "The string after addslashes is:"
159
string(33) "The string after stripslashes is:"
162
string(31) "The string after addslashes is:"
164
string(33) "The string after stripslashes is:"
167
string(31) "The string after addslashes is:"
168
string(25) "Is your name Ram\Krishna?"
169
string(33) "The string after stripslashes is:"
170
string(25) "Is your name Ram\Krishna?"
172
string(31) "The string after addslashes is:"
173
string(28) "c:\php\testcase\stripslashes"
174
string(33) "The string after stripslashes is:"
175
string(28) "c:\php\testcase\stripslashes"
177
string(31) "The string after addslashes is:"
179
string(33) "The string after stripslashes is:"
182
string(31) "The string after addslashes is:"
183
string(12) "hello\0world"
184
string(33) "The string after stripslashes is:"
185
string(11) "hello world"
187
string(31) "The string after addslashes is:"
188
string(9) "\0hello\0"
189
string(33) "The string after stripslashes is:"