ob_implicit_flush_variation_001.phpt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. --TEST--
  2. Test ob_implicit_flush() function : usage variation
  3. --SKIPIF--
  4. <?php if (PHP_INT_SIZE != 8) die("skip this test is for 64-bit only");
  5. --FILE--
  6. <?php
  7. /* Prototype : void ob_implicit_flush([int flag])
  8. * Description: Turn implicit flush on/off and is equivalent to calling flush() after every output call
  9. * Source code: main/output.c
  10. * Alias to functions:
  11. */
  12. echo "*** Testing ob_implicit_flush() : usage variation ***\n";
  13. // Define error handler
  14. function 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. }
  20. set_error_handler('test_error_handler');
  21. // Initialise function arguments not being substituted (if any)
  22. //get an unset variable
  23. $unset_var = 10;
  24. unset ($unset_var);
  25. // define some classes
  26. class classWithToString
  27. {
  28. public function __toString() {
  29. return "Class A object";
  30. }
  31. }
  32. class classWithoutToString
  33. {
  34. }
  35. // heredoc string
  36. $heredoc = <<<EOT
  37. hello world
  38. EOT;
  39. // add arrays
  40. $index_array = array (1, 2, 3);
  41. $assoc_array = array ('one' => 1, 'two' => 2);
  42. //array of values to iterate over
  43. $inputs = array(
  44. // float data
  45. 'float 10.5' => 10.5,
  46. 'float -10.5' => -10.5,
  47. 'float 12.3456789000e10' => 12.3456789000e10,
  48. 'float -12.3456789000e10' => -12.3456789000e10,
  49. 'float .5' => .5,
  50. // array data
  51. 'empty array' => array(),
  52. 'int indexed array' => $index_array,
  53. 'associative array' => $assoc_array,
  54. 'nested arrays' => array('foo', $index_array, $assoc_array),
  55. // null data
  56. 'uppercase NULL' => NULL,
  57. 'lowercase null' => null,
  58. // boolean data
  59. 'lowercase true' => true,
  60. 'lowercase false' =>false,
  61. 'uppercase TRUE' =>TRUE,
  62. 'uppercase FALSE' =>FALSE,
  63. // empty data
  64. 'empty string DQ' => "",
  65. 'empty string SQ' => '',
  66. // string data
  67. 'string DQ' => "string",
  68. 'string SQ' => 'string',
  69. 'mixed case string' => "sTrInG",
  70. 'heredoc' => $heredoc,
  71. // object data
  72. 'instance of classWithToString' => new classWithToString(),
  73. 'instance of classWithoutToString' => new classWithoutToString(),
  74. // undefined data
  75. 'undefined var' => @$undefined_var,
  76. // unset data
  77. 'unset var' => @$unset_var,
  78. );
  79. // loop through each element of the array for flag
  80. foreach($inputs as $key =>$value) {
  81. echo "\n--$key--\n";
  82. var_dump( ob_implicit_flush($value) );
  83. };
  84. ?>
  85. --EXPECTF--
  86. *** Testing ob_implicit_flush() : usage variation ***
  87. --float 10.5--
  88. NULL
  89. --float -10.5--
  90. NULL
  91. --float 12.3456789000e10--
  92. NULL
  93. --float -12.3456789000e10--
  94. NULL
  95. --float .5--
  96. NULL
  97. --empty array--
  98. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, array given, %s(97)
  99. NULL
  100. --int indexed array--
  101. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, array given, %s(97)
  102. NULL
  103. --associative array--
  104. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, array given, %s(97)
  105. NULL
  106. --nested arrays--
  107. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, array given, %s(97)
  108. NULL
  109. --uppercase NULL--
  110. NULL
  111. --lowercase null--
  112. NULL
  113. --lowercase true--
  114. NULL
  115. --lowercase false--
  116. NULL
  117. --uppercase TRUE--
  118. NULL
  119. --uppercase FALSE--
  120. NULL
  121. --empty string DQ--
  122. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, string given, %s(97)
  123. NULL
  124. --empty string SQ--
  125. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, string given, %s(97)
  126. NULL
  127. --string DQ--
  128. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, string given, %s(97)
  129. NULL
  130. --string SQ--
  131. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, string given, %s(97)
  132. NULL
  133. --mixed case string--
  134. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, string given, %s(97)
  135. NULL
  136. --heredoc--
  137. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, string given, %s(97)
  138. NULL
  139. --instance of classWithToString--
  140. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, object given, %s(97)
  141. NULL
  142. --instance of classWithoutToString--
  143. Error: 2 - ob_implicit_flush() expects parameter 1 to be int, object given, %s(97)
  144. NULL
  145. --undefined var--
  146. NULL
  147. --unset var--
  148. NULL