ob_implicit_flush_variation_001.phpt [plain text]
--TEST--
Test ob_implicit_flush() function : usage variation
--SKIPIF--
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64-bit only");
--FILE--
<?php
echo "*** Testing ob_implicit_flush() : usage variation ***\n";
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
if (error_reporting() != 0) {
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
}
}
set_error_handler('test_error_handler');
$unset_var = 10;
unset ($unset_var);
class classWithToString
{
public function __toString() {
return "Class A object";
}
}
class classWithoutToString
{
}
$heredoc = <<<EOT
hello world
EOT;
$index_array = array (1, 2, 3);
$assoc_array = array ('one' => 1, 'two' => 2);
$inputs = array(
'float 10.5' => 10.5,
'float -10.5' => -10.5,
'float 12.3456789000e10' => 12.3456789000e10,
'float -12.3456789000e10' => -12.3456789000e10,
'float .5' => .5,
'empty array' => array(),
'int indexed array' => $index_array,
'associative array' => $assoc_array,
'nested arrays' => array('foo', $index_array, $assoc_array),
'uppercase NULL' => NULL,
'lowercase null' => null,
'lowercase true' => true,
'lowercase false' =>false,
'uppercase TRUE' =>TRUE,
'uppercase FALSE' =>FALSE,
'empty string DQ' => "",
'empty string SQ' => '',
'string DQ' => "string",
'string SQ' => 'string',
'mixed case string' => "sTrInG",
'heredoc' => $heredoc,
'instance of classWithToString' => new classWithToString(),
'instance of classWithoutToString' => new classWithoutToString(),
'undefined var' => @$undefined_var,
'unset var' => @$unset_var,
);
foreach($inputs as $key =>$value) {
echo "\n--$key--\n";
var_dump( ob_implicit_flush($value) );
};
?>
--EXPECTF--
*** Testing ob_implicit_flush() : usage variation ***
--float 10.5--
NULL
--float -10.5--
NULL
--float 12.3456789000e10--
NULL
--float -12.3456789000e10--
NULL
--float .5--
NULL
--empty array--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, array given, %s(97)
NULL
--int indexed array--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, array given, %s(97)
NULL
--associative array--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, array given, %s(97)
NULL
--nested arrays--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, array given, %s(97)
NULL
--uppercase NULL--
NULL
--lowercase null--
NULL
--lowercase true--
NULL
--lowercase false--
NULL
--uppercase TRUE--
NULL
--uppercase FALSE--
NULL
--empty string DQ--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, %unicode_string_optional% given, %s(97)
NULL
--empty string SQ--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, %unicode_string_optional% given, %s(97)
NULL
--string DQ--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, %unicode_string_optional% given, %s(97)
NULL
--string SQ--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, %unicode_string_optional% given, %s(97)
NULL
--mixed case string--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, %unicode_string_optional% given, %s(97)
NULL
--heredoc--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, %unicode_string_optional% given, %s(97)
NULL
--instance of classWithToString--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, object given, %s(97)
NULL
--instance of classWithoutToString--
Error: 2 - ob_implicit_flush() expects parameter 1 to be integer, object given, %s(97)
NULL
--undefined var--
NULL
--unset var--
NULL