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  2,
13  array(5,6,7),
14  "a",
15  "\0",
16  "\n",
17  "\r",
18  "\t",
19  "\a",
20  "\v",
21  "\b",
22  "\f"
23);
24/* loop prints string with backslashes before characters
25   mentioned in $char using addcslashes() */
26$counter = 1;
27foreach($charlist as $char) {
28  echo "-- Iteration $counter --\n";
29  try {
30    var_dump( addcslashes($string, $char) );
31  } catch (TypeError $e) {
32    echo $e->getMessage(), "\n";
33  }
34  $counter++;
35}
36
37echo "Done\n";
38
39?>
40--EXPECTF--
41*** Testing addcslashes() for basic operations ***
42-- Iteration 1 --
43string(37) "goodyear1\2345NULL%0truefalse\a\b
44
44	"
45-- Iteration 2 --
46addcslashes(): Argument #2 ($characters) must be of type string, array given
47-- Iteration 3 --
48string(39) "goodye\ar12345NULL%0truef\alse\\a\b
49
49	"
50-- Iteration 4 --
51string(39) "goodyear12345NULL\000truefalse\a\b
52
52	"
53-- Iteration 5 --
54string(37) "goodyear12345NULL%0truefalse\a\b\n
54	"
55-- Iteration 6 --
56string(37) "goodyear12345NULL%0truefalse\a\b
57\r	"
58-- Iteration 7 --
59string(37) "goodyear12345NULL%0truefalse\a\b
60
60\t"
61-- Iteration 8 --
62string(41) "goodye\ar12345NULL%0truef\alse\\\a\\b
63
63	"
64-- Iteration 9 --
65string(37) "goodyear12345NULL%0truefalse\a\v\b
66
66	"
67-- Iteration 10 --
68string(39) "goodyear12345NULL%0truefalse\\a\\\b
69
69	"
70-- Iteration 11 --
71string(37) "goodyear12345NULL%0truefalse\a\f\b
72
72	"
73Done
74