ob_start_basic_006.phpt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. --TEST--
  2. ob_start(): ensure multiple buffer initialization with a single call using arrays is not supported on PHP6 (http://bugs.php.net/42641)
  3. --FILE--
  4. <?php
  5. /*
  6. * proto bool ob_start([ string|array user_function [, int chunk_size [, bool erase]]])
  7. * Function is implemented in main/output.c
  8. */
  9. function f($string) {
  10. static $i=0;
  11. $i++;
  12. $len = strlen($string);
  13. return "f[call:$i; len:$len] - $string\n";
  14. }
  15. Class C {
  16. public $id = 'none';
  17. function __construct($id) {
  18. $this->id = $id;
  19. }
  20. static function g($string) {
  21. static $i=0;
  22. $i++;
  23. $len = strlen($string);
  24. return "C::g[call:$i; len:$len] - $string\n";
  25. }
  26. function h($string) {
  27. static $i=0;
  28. $i++;
  29. $len = strlen($string);
  30. return "C::h[call:$i; len:$len; id:$this->id] - $string\n";
  31. }
  32. }
  33. function checkAndClean() {
  34. print_r(ob_list_handlers());
  35. while (ob_get_level()>0) {
  36. ob_end_flush();
  37. }
  38. }
  39. echo "\n ---> Test arrays: \n";
  40. var_dump(ob_start(array("f")));
  41. checkAndClean();
  42. var_dump(ob_start(array("f", "f")));
  43. checkAndClean();
  44. var_dump(ob_start(array("f", "C::g", "f", "C::g")));
  45. checkAndClean();
  46. var_dump(ob_start(array("f", "non_existent", "f")));
  47. checkAndClean();
  48. var_dump(ob_start(array("f", "non_existent", "f", "f")));
  49. checkAndClean();
  50. $c = new c('originalID');
  51. var_dump(ob_start(array($c, "h")));
  52. checkAndClean();
  53. var_dump(ob_start(array($c, "h")));
  54. $c->id = 'changedID';
  55. checkAndClean();
  56. $c->id = 'changedIDagain';
  57. var_dump(ob_start(array('f', 'C::g', array(array($c, "g"), array($c, "h")))));
  58. checkAndClean();
  59. ?>
  60. --EXPECTF--
  61. ---> Test arrays:
  62. Warning: ob_start(): array must have exactly two members in %s on line 44
  63. Notice: ob_start(): failed to create buffer in %s on line 44
  64. bool(false)
  65. Array
  66. (
  67. )
  68. Warning: ob_start(): class 'f' not found in %s on line 47
  69. Notice: ob_start(): failed to create buffer in %s on line 47
  70. bool(false)
  71. Array
  72. (
  73. )
  74. Warning: ob_start(): array must have exactly two members in %s on line 50
  75. Notice: ob_start(): failed to create buffer in %s on line 50
  76. bool(false)
  77. Array
  78. (
  79. )
  80. Warning: ob_start(): array must have exactly two members in %s on line 53
  81. Notice: ob_start(): failed to create buffer in %s on line 53
  82. bool(false)
  83. Array
  84. (
  85. )
  86. Warning: ob_start(): array must have exactly two members in %s on line 56
  87. Notice: ob_start(): failed to create buffer in %s on line 56
  88. bool(false)
  89. Array
  90. (
  91. )
  92. C::h[call:1; len:37; id:originalID] - bool(true)
  93. Array
  94. (
  95. [0] => C::h
  96. )
  97. C::h[call:2; len:37; id:changedID] - bool(true)
  98. Array
  99. (
  100. [0] => C::h
  101. )
  102. Warning: ob_start(): array must have exactly two members in %s on line 68
  103. Notice: ob_start(): failed to create buffer in %s on line 68
  104. bool(false)
  105. Array
  106. (
  107. )