import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-array / array_shift_variation2.php
blob820983bfaccb96fdb3e74dd3a03297030dbaa00b
1 <?php
2 /* Prototype : mixed array_shift(array &$stack)
3 * Description: Pops an element off the beginning of the array
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * Pass arrays where values are of one data type to test behaviour of array_shift()
9 */
11 echo "*** Testing array_shift() : usage variations ***\n";
14 //get an unset variable
15 $unset_var = 10;
16 unset ($unset_var);
18 // get a class
19 class classA
21 public function __toString() {
22 return "Class A object";
26 // heredoc string
27 $heredoc = <<<EOT
28 hello world
29 EOT;
31 // get a resource variable
32 $fp = fopen(__FILE__, "r");
34 // arrays of different data types to be passed to $stack argument
35 $inputs = array(
37 // int data
38 /*1*/ 'int' => array(
41 12345,
42 -2345,
45 // float data
46 /*2*/ 'float' => array(
47 10.5,
48 -10.5,
49 12.3456789000e10,
50 12.3456789000E-10,
51 .5,
54 // null data
55 /*3*/ 'null' => array(
56 NULL,
57 null,
60 // boolean data
61 /*4*/ 'bool' => array(
62 true,
63 false,
64 TRUE,
65 FALSE,
68 // empty data
69 /*5*/ 'empty string' => array(
70 "",
71 '',
74 /*6*/ 'empty array' => array(
77 // string data
78 /*7*/ 'string' => array(
79 "string",
80 'string',
81 $heredoc,
84 // object data
85 /*8*/ 'object' => array(
86 new classA(),
89 // undefined data
90 /*9*/ 'undefined' => array(
91 @$undefined_var,
94 // unset data
95 /*10*/ 'unset' => array(
96 @$unset_var,
99 // resource variable
100 /*11*/ 'resource' => array(
105 // loop through each element of $inputs to check the behavior of array_shift
106 $iterator = 1;
107 foreach($inputs as $key => $input) {
108 echo "\n-- Iteration $iterator: $key data --\n";
109 var_dump( array_shift($input) );
110 var_dump($input);
111 $iterator++;
114 fclose($fp);
117 echo "Done";