1--TEST--
2Test array_fill() function : usage variations  - unexpected values for 'val' argument
3--FILE--
4<?php
5/*
6 * testing array_fill() by passing different unexpected values for 'val' argument
7 */
8
9echo "*** Testing array_fill() : usage variations ***\n";
10
11// Initialise function arguments not being substituted
12$start_key = 0;
13$num = 2;
14
15//get an unset variable
16$unset_var = 10;
17unset ($unset_var);
18
19// define a class
20class test
21{
22  var $t = 10;
23  function __toString()
24  {
25    return "testObject";
26  }
27}
28
29
30//array of different values for 'val' argument
31$values = array(
32            // empty string
33  /* 1  */  "",
34            '',
35            // objects
36  /* 3  */  new test(),
37
38            // undefined variable
39            @$undefined_var,
40
41            // unset variable
42  /* 5  */  @$unset_var,
43);
44
45// loop through each element of the array for 'val' argument
46// check the working of array_fill()
47echo "--- Testing array_fill() with different values for 'val' argument ---\n";
48$counter = 1;
49for($index = 0; $index < count($values); $index ++)
50{
51  echo "-- Iteration $counter --\n";
52  $val = $values[$index];
53
54  var_dump( array_fill($start_key , $num , $val) );
55
56  $counter++;
57}
58
59echo"Done";
60?>
61--EXPECTF--
62*** Testing array_fill() : usage variations ***
63--- Testing array_fill() with different values for 'val' argument ---
64-- Iteration 1 --
65array(2) {
66  [0]=>
67  string(0) ""
68  [1]=>
69  string(0) ""
70}
71-- Iteration 2 --
72array(2) {
73  [0]=>
74  string(0) ""
75  [1]=>
76  string(0) ""
77}
78-- Iteration 3 --
79array(2) {
80  [0]=>
81  object(test)#%d (1) {
82    ["t"]=>
83    int(10)
84  }
85  [1]=>
86  object(test)#%d (1) {
87    ["t"]=>
88    int(10)
89  }
90}
91-- Iteration 4 --
92array(2) {
93  [0]=>
94  NULL
95  [1]=>
96  NULL
97}
98-- Iteration 5 --
99array(2) {
100  [0]=>
101  NULL
102  [1]=>
103  NULL
104}
105Done
106