1--TEST--
2Test addcslashes() function (variation 1)
3--INI--
4precision=14
5--FILE--
6<?php
7
8echo "*** Testing addcslashes() for basic operations ***\n";
9/* checking normal operation of addcslashes */
10$string = "goodyear12345NULL\0truefalse\a\v\f\b\n\r\t";
11$charlist = array (
12  NULL,
13  2,
14  array(5,6,7),
15  "a",
16  "\0",
17  "\n",
18  "\r",
19  "\t",
20  "\a",
21  "\v",
22  "\b",
23  "\f"
24);
25/* loop prints string with backslashes before characters
26   mentioned in $char using addcslashes() */
27$counter = 1;
28foreach($charlist as $char) {
29  echo "-- Iteration $counter --\n";
30  var_dump( addcslashes($string, $char) );
31  $counter++;
32}
33
34echo "Done\n";
35
36?>
37--EXPECTF--
38*** Testing addcslashes() for basic operations ***
39-- Iteration 1 --
40string(36) "goodyear12345NULL�truefalse\a\b
41
41	"
42-- Iteration 2 --
43string(37) "goodyear1\2345NULL�truefalse\a\b
44
44	"
45-- Iteration 3 --
46
47Warning: addcslashes() expects parameter 2 to be string, array given in %s on line %d
48NULL
49-- Iteration 4 --
50string(39) "goodye\ar12345NULL�truef\alse\\a\b
51
51	"
52-- Iteration 5 --
53string(39) "goodyear12345NULL\000truefalse\a\b
54
54	"
55-- Iteration 6 --
56string(37) "goodyear12345NULL�truefalse\a\b\n
56	"
57-- Iteration 7 --
58string(37) "goodyear12345NULL�truefalse\a\b
59\r	"
60-- Iteration 8 --
61string(37) "goodyear12345NULL�truefalse\a\b
62
62\t"
63-- Iteration 9 --
64string(41) "goodye\ar12345NULL�truef\alse\\\a\\b
65
65	"
66-- Iteration 10 --
67string(37) "goodyear12345NULL�truefalse\a\v\b
68
68	"
69-- Iteration 11 --
70string(39) "goodyear12345NULL�truefalse\\a\\\b
71
71	"
72-- Iteration 12 --
73string(37) "goodyear12345NULL�truefalse\a\f\b
74
74	"
75Done
76