1--TEST--
2Test wordwrap() function : usage variations  - unexptected value for cut argument
3--FILE--
4<?php
5/* Prototype  : string wordwrap ( string $str [, int $width [, string $break [, bool $cut]]] )
6 * Description: Wraps buffer to selected number of characters using string break char
7 * Source code: ext/standard/string.c
8*/
9
10/*
11 * test wordwrap() by supplying different values for cut argument
12*/
13
14echo "*** Testing wordwrap() : usage variations ***\n";
15// initialize all required variables
16$str = 'testing wordwrap function';
17$width = 10;
18$break = '<br />\n';
19
20// get an unset variable
21$unset_var = true;
22unset($unset_var);
23
24// resource variable
25$fp = fopen(__FILE__, "r");
26
27// array with different values
28$values =  array (
29
30  // integer values
31  0,
32  1,
33  12345,
34  -2345,
35
36  // float values
37  10.5,
38  -10.5,
39  10.5e10,
40  10.6E-10,
41  .5,
42
43  // array values
44  array(),
45  array(0),
46  array(1),
47  array(1, 2),
48  array('color' => 'red', 'item' => 'pen'),
49
50  // string values
51  "string",
52  'string',
53
54  // objects
55  new stdclass(),
56
57  // empty string
58  "",
59  '',
60
61  // undefined variable
62  @$undefined_var,
63
64  // unset variable
65  @$unset_var
66);
67
68// loop though each element of the array and check the working of wordwrap()
69// when $cut argument is supplied with different values
70echo "\n--- Testing wordwrap() by supplying different values for 'cut' argument ---\n";
71$counter = 1;
72for($index = 0; $index < count($values); $index ++) {
73  echo "-- Iteration $counter --\n";
74  $cut = $values [$index];
75
76  var_dump( wordwrap($str, $width, $break, $cut) );
77
78  $counter ++;
79}
80
81// close the resource
82fclose($fp);
83
84echo "Done\n";
85?>
86--EXPECTF--
87*** Testing wordwrap() : usage variations ***
88
89--- Testing wordwrap() by supplying different values for 'cut' argument ---
90-- Iteration 1 --
91string(39) "testing<br />\nwordwrap<br />\nfunction"
92-- Iteration 2 --
93string(39) "testing<br />\nwordwrap<br />\nfunction"
94-- Iteration 3 --
95string(39) "testing<br />\nwordwrap<br />\nfunction"
96-- Iteration 4 --
97string(39) "testing<br />\nwordwrap<br />\nfunction"
98-- Iteration 5 --
99string(39) "testing<br />\nwordwrap<br />\nfunction"
100-- Iteration 6 --
101string(39) "testing<br />\nwordwrap<br />\nfunction"
102-- Iteration 7 --
103string(39) "testing<br />\nwordwrap<br />\nfunction"
104-- Iteration 8 --
105string(39) "testing<br />\nwordwrap<br />\nfunction"
106-- Iteration 9 --
107string(39) "testing<br />\nwordwrap<br />\nfunction"
108-- Iteration 10 --
109
110Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on line %d
111NULL
112-- Iteration 11 --
113
114Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on line %d
115NULL
116-- Iteration 12 --
117
118Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on line %d
119NULL
120-- Iteration 13 --
121
122Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on line %d
123NULL
124-- Iteration 14 --
125
126Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on line %d
127NULL
128-- Iteration 15 --
129string(39) "testing<br />\nwordwrap<br />\nfunction"
130-- Iteration 16 --
131string(39) "testing<br />\nwordwrap<br />\nfunction"
132-- Iteration 17 --
133
134Warning: wordwrap() expects parameter 4 to be boolean, object given in %s on line %d
135NULL
136-- Iteration 18 --
137string(39) "testing<br />\nwordwrap<br />\nfunction"
138-- Iteration 19 --
139string(39) "testing<br />\nwordwrap<br />\nfunction"
140-- Iteration 20 --
141string(39) "testing<br />\nwordwrap<br />\nfunction"
142-- Iteration 21 --
143string(39) "testing<br />\nwordwrap<br />\nfunction"
144Done
145