import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-array / array_slice_variation3.php
blobe4df3377c10197e49ebc1d6badf3185c20b6888a
1 <?php
2 /* Prototype : array array_slice(array $input, int $offset [, int $length [, bool $preserve_keys]])
3 * Description: Returns elements specified by offset and length
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * Pass different data types as $length argument to array_slice to test behaviour
9 */
11 echo "*** Testing array_slice() : usage variations ***\n";
13 // Initialise function arguments not being substituted
14 $input_array = array('one' => 1, 2, 'three' => 3, 4);
15 $offset = 2;
17 //get an unset variable
18 $unset_var = 10;
19 unset ($unset_var);
21 // heredoc string
22 $heredoc = <<<EOT
23 hello world
24 EOT;
26 // unexpected values to be passed to $length argument
27 $inputs = array(
29 // int data
30 /*1*/ 0,
32 12345,
33 -2345,
35 // float data
36 /*5*/ 10.5,
37 -10.5,
38 12.3456789000e10,
39 12.3456789000E-10,
40 .5,
42 // null data
43 /*10*/ NULL,
44 null,
46 // boolean data
47 /*12*/ true,
48 false,
49 TRUE,
50 FALSE,
52 // empty data
53 /*16*/ "",
54 '',
55 array(),
57 // string data
58 /*19*/ "string",
59 'string',
60 $heredoc,
62 // undefined data
63 /*22*/ @$undefined_var,
65 // unset data
66 /*23*/ @$unset_var,
69 // loop through each element of $inputs to check the behavior of array_slice
70 $iterator = 1;
71 foreach($inputs as $input) {
72 echo "\n-- Iteration $iterator --\n";
73 var_dump( array_slice($input_array, $offset, $input) );
74 $iterator++;
77 echo "Done";