import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-array / array_shift_variation1.php
blob87557b201a1ba857ba0f3b91bec7b7d64def49aa
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 different data types as $stack argument to array_shift() to test behaviour
9 */
11 echo "*** Testing array_shift() : usage variations ***\n";
13 //get an unset variable
14 $unset_var = 10;
15 unset ($unset_var);
17 // get a class
18 class classA
20 public function __toString() {
21 return "Class A object";
25 // heredoc string
26 $heredoc = <<<EOT
27 hello world
28 EOT;
30 // get a resource variable
31 $fp = fopen(__FILE__, "r");
33 // unexpected values to be passed to $stack argument
34 $inputs = array(
36 // int data
37 /*1*/ 0,
39 12345,
40 -2345,
42 // float data
43 /*5*/ 10.5,
44 -10.5,
45 12.3456789000e10,
46 12.3456789000E-10,
47 .5,
49 // null data
50 /*10*/ NULL,
51 null,
53 // boolean data
54 /*12*/ true,
55 false,
56 TRUE,
57 FALSE,
59 // empty data
60 /*16*/ "",
61 '',
63 // string data
64 /*18*/ "string",
65 'string',
66 $heredoc,
68 // object data
69 /*21*/ new classA(),
71 // undefined data
72 /*22*/ @$undefined_var,
74 // unset data
75 /*23*/ @$unset_var,
77 // resource variable
78 /*24*/ $fp
81 // loop through each element of $inputs to check the behavior of array_shift()
82 $iterator = 1;
83 foreach($inputs as $input) {
84 echo "\n-- Iteration $iterator --\n";
85 var_dump( array_shift($input) );
86 $iterator++;
89 fclose($fp);
91 echo "Done";