import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / wordwrap_variation4.php
blob4e4fd64f9563aa50fb5a9971a4d1e75173a221fd
1 <?php
2 /* Prototype : string wordwrap ( string $str [, int $width [, string $break [, bool $cut]]] )
3 * Description: Wraps buffer to selected number of characters using string break char
4 * Source code: ext/standard/string.c
5 */
7 /*
8 * test wordwrap() by supplying different values for cut argument
9 */
11 echo "*** Testing wordwrap() : usage variations ***\n";
12 // initialize all required variables
13 $str = 'testing wordwrap function';
14 $width = 10;
15 $break = '<br />\n';
17 // get an unset variable
18 $unset_var = true;
19 unset($unset_var);
21 // resource variable
22 $fp = fopen(__FILE__, "r");
24 // array with different values
25 $values = array (
27 // integer values
30 12345,
31 -2345,
33 // float values
34 10.5,
35 -10.5,
36 10.5e10,
37 10.6E-10,
38 .5,
40 // array values
41 array(),
42 array(0),
43 array(1),
44 array(1, 2),
45 array('color' => 'red', 'item' => 'pen'),
47 // string values
48 "string",
49 'string',
51 // objects
52 new stdclass(),
54 // empty string
55 "",
56 '',
58 // undefined variable
59 @$undefined_var,
61 // unset variable
62 @$unset_var
65 // loop though each element of the array and check the working of wordwrap()
66 // when $cut arugment is supplied with different values
67 echo "\n--- Testing wordwrap() by supplying different values for 'cut' argument ---\n";
68 $counter = 1;
69 for($index = 0; $index < count($values); $index ++) {
70 echo "-- Iteration $counter --\n";
71 $cut = $values [$index];
73 var_dump( wordwrap($str, $width, $break, $cut) );
75 $counter ++;
78 // close the resource
79 fclose($fp);
81 echo "Done\n";