1--TEST--
2Test ob_implicit_flush() function : usage variation
3--FILE--
4<?php
5/* Prototype  : void ob_implicit_flush([int flag])
6 * Description: Turn implicit flush on/off and is equivalent to calling flush() after every output call
7 * Source code: main/output.c
8 * Alias to functions:
9 */
10
11echo "*** Testing ob_implicit_flush() : usage variation ***\n";
12
13// Define error handler
14function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
15	if (error_reporting() != 0) {
16		// report non-silenced errors
17		echo "Error: $err_no - $err_msg, $filename($linenum)\n";
18	}
19}
20set_error_handler('test_error_handler');
21
22// Initialise function arguments not being substituted (if any)
23
24//get an unset variable
25$unset_var = 10;
26unset ($unset_var);
27
28// define some classes
29class classWithToString
30{
31	public function __toString() {
32		return "Class A object";
33	}
34}
35
36class classWithoutToString
37{
38}
39
40// heredoc string
41$heredoc = <<<EOT
42hello world
43EOT;
44
45// add arrays
46$index_array = array (1, 2, 3);
47$assoc_array = array ('one' => 1, 'two' => 2);
48
49//array of values to iterate over
50$inputs = array(
51
52      // float data
53      'float 10.5' => 10.5,
54      'float -10.5' => -10.5,
55      'float 12.3456789000e10' => 12.3456789000e10,
56      'float -12.3456789000e10' => -12.3456789000e10,
57      'float .5' => .5,
58
59      // array data
60      'empty array' => array(),
61      'int indexed array' => $index_array,
62      'associative array' => $assoc_array,
63      'nested arrays' => array('foo', $index_array, $assoc_array),
64
65      // null data
66      'uppercase NULL' => NULL,
67      'lowercase null' => null,
68
69      // boolean data
70      'lowercase true' => true,
71      'lowercase false' =>false,
72      'uppercase TRUE' =>TRUE,
73      'uppercase FALSE' =>FALSE,
74
75      // empty data
76      'empty string DQ' => "",
77      'empty string SQ' => '',
78
79      // string data
80      'string DQ' => "string",
81      'string SQ' => 'string',
82      'mixed case string' => "sTrInG",
83      'heredoc' => $heredoc,
84
85      // object data
86      'instance of classWithToString' => new classWithToString(),
87      'instance of classWithoutToString' => new classWithoutToString(),
88
89      // undefined data
90      'undefined var' => @$undefined_var,
91
92      // unset data
93      'unset var' => @$unset_var,
94);
95
96// loop through each element of the array for flag
97
98foreach($inputs as $key =>$value) {
99      echo "\n--$key--\n";
100      var_dump( ob_implicit_flush($value) );
101};
102
103?>
104--EXPECTF--
105*** Testing ob_implicit_flush() : usage variation ***
106
107--float 10.5--
108NULL
109
110--float -10.5--
111NULL
112
113--float 12.3456789000e10--
114NULL
115
116--float -12.3456789000e10--
117NULL
118
119--float .5--
120NULL
121
122--empty array--
123Error: 2 - ob_implicit_flush() expects parameter 1 to be long, array given, %s(97)
124NULL
125
126--int indexed array--
127Error: 2 - ob_implicit_flush() expects parameter 1 to be long, array given, %s(97)
128NULL
129
130--associative array--
131Error: 2 - ob_implicit_flush() expects parameter 1 to be long, array given, %s(97)
132NULL
133
134--nested arrays--
135Error: 2 - ob_implicit_flush() expects parameter 1 to be long, array given, %s(97)
136NULL
137
138--uppercase NULL--
139NULL
140
141--lowercase null--
142NULL
143
144--lowercase true--
145NULL
146
147--lowercase false--
148NULL
149
150--uppercase TRUE--
151NULL
152
153--uppercase FALSE--
154NULL
155
156--empty string DQ--
157Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
158NULL
159
160--empty string SQ--
161Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
162NULL
163
164--string DQ--
165Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
166NULL
167
168--string SQ--
169Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
170NULL
171
172--mixed case string--
173Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
174NULL
175
176--heredoc--
177Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
178NULL
179
180--instance of classWithToString--
181Error: 2 - ob_implicit_flush() expects parameter 1 to be long, object given, %s(97)
182NULL
183
184--instance of classWithoutToString--
185Error: 2 - ob_implicit_flush() expects parameter 1 to be long, object given, %s(97)
186NULL
187
188--undefined var--
189NULL
190
191--unset var--
192NULL