ob_start_basic_006.phpt 2.6 KB

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