import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-array / end_variation1.php
blob3ebee4bf6ad3566821944289eb36c7243cef5191
1 <?php
2 /* Prototype : mixed end(array $array_arg)
3 * Description: Advances array argument's internal pointer to the last element and return it
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * Pass different data types as $array_arg to test behaviour of end()
9 */
11 echo "*** Testing end() : usage variations ***\n";
13 //get an unset variable
14 $unset_var = 10;
15 unset ($unset_var);
17 // get a class
18 class classA
20 var $foo = 'hello, world';
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 // unexpected values to be passed to $array_arg argument
35 $inputs = array(
37 // int data
38 /*1*/ 0,
40 12345,
41 -2345,
43 // float data
44 /*5*/ 10.5,
45 -10.5,
46 12.3456789000e10,
47 12.3456789000E-10,
48 .5,
50 // null data
51 /*10*/ NULL,
52 null,
54 // boolean data
55 /*12*/ true,
56 false,
57 TRUE,
58 FALSE,
60 // empty data
61 /*16*/ "",
62 '',
63 array(),
65 // string data
66 /*19*/ "string",
67 'string',
68 $heredoc,
70 // object data
71 /*22*/ new classA(),
73 // undefined data
74 /*23*/ @$undefined_var,
76 // unset data
77 /*24*/ @$unset_var,
79 // resource variable
80 /*25*/ $fp
83 // loop through each element of $inputs to check the behavior of end()
84 $iterator = 1;
85 foreach($inputs as $input) {
86 echo "\n-- Iteration $iterator --\n";
87 var_dump( end($input) );
88 $iterator++;
91 fclose($fp);
93 ===DONE===