ob_start_basic_004.phpt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. --TEST--
  2. ob_start() chunk_size: confirm buffer is flushed after any output call that causes its length to equal or exceed chunk_size.
  3. --INI--
  4. opcache.optimization_level=0
  5. --FILE--
  6. <?php
  7. /*
  8. * Function is implemented in main/output.c
  9. */
  10. // In HEAD, $chunk_size value of 1 should not have any special behaviour (http://marc.info/?l=php-internals&m=123476465621346&w=2).
  11. function callback($string) {
  12. global $callback_invocations;
  13. $callback_invocations++;
  14. $len = strlen($string);
  15. return "f[call:$callback_invocations; len:$len]$string\n";
  16. }
  17. for ($cs=-1; $cs<10; $cs++) {
  18. echo "\n----( chunk_size: $cs, output append size: 1 )----\n";
  19. $callback_invocations=0;
  20. ob_start('callback', $cs);
  21. echo '1'; echo '2'; echo '3'; echo '4'; echo '5'; echo '6'; echo '7'; echo '8';
  22. ob_end_flush();
  23. }
  24. for ($cs=-1; $cs<10; $cs++) {
  25. echo "\n----( chunk_size: $cs, output append size: 4 )----\n";
  26. $callback_invocations=0;
  27. ob_start('callback', $cs);
  28. echo '1234'; echo '5678';
  29. ob_end_flush();
  30. }
  31. ?>
  32. --EXPECT--
  33. ----( chunk_size: -1, output append size: 1 )----
  34. f[call:1; len:8]12345678
  35. ----( chunk_size: 0, output append size: 1 )----
  36. f[call:1; len:8]12345678
  37. ----( chunk_size: 1, output append size: 1 )----
  38. f[call:1; len:1]1
  39. f[call:2; len:1]2
  40. f[call:3; len:1]3
  41. f[call:4; len:1]4
  42. f[call:5; len:1]5
  43. f[call:6; len:1]6
  44. f[call:7; len:1]7
  45. f[call:8; len:1]8
  46. f[call:9; len:0]
  47. ----( chunk_size: 2, output append size: 1 )----
  48. f[call:1; len:2]12
  49. f[call:2; len:2]34
  50. f[call:3; len:2]56
  51. f[call:4; len:2]78
  52. f[call:5; len:0]
  53. ----( chunk_size: 3, output append size: 1 )----
  54. f[call:1; len:3]123
  55. f[call:2; len:3]456
  56. f[call:3; len:2]78
  57. ----( chunk_size: 4, output append size: 1 )----
  58. f[call:1; len:4]1234
  59. f[call:2; len:4]5678
  60. f[call:3; len:0]
  61. ----( chunk_size: 5, output append size: 1 )----
  62. f[call:1; len:5]12345
  63. f[call:2; len:3]678
  64. ----( chunk_size: 6, output append size: 1 )----
  65. f[call:1; len:6]123456
  66. f[call:2; len:2]78
  67. ----( chunk_size: 7, output append size: 1 )----
  68. f[call:1; len:7]1234567
  69. f[call:2; len:1]8
  70. ----( chunk_size: 8, output append size: 1 )----
  71. f[call:1; len:8]12345678
  72. f[call:2; len:0]
  73. ----( chunk_size: 9, output append size: 1 )----
  74. f[call:1; len:8]12345678
  75. ----( chunk_size: -1, output append size: 4 )----
  76. f[call:1; len:8]12345678
  77. ----( chunk_size: 0, output append size: 4 )----
  78. f[call:1; len:8]12345678
  79. ----( chunk_size: 1, output append size: 4 )----
  80. f[call:1; len:4]1234
  81. f[call:2; len:4]5678
  82. f[call:3; len:0]
  83. ----( chunk_size: 2, output append size: 4 )----
  84. f[call:1; len:4]1234
  85. f[call:2; len:4]5678
  86. f[call:3; len:0]
  87. ----( chunk_size: 3, output append size: 4 )----
  88. f[call:1; len:4]1234
  89. f[call:2; len:4]5678
  90. f[call:3; len:0]
  91. ----( chunk_size: 4, output append size: 4 )----
  92. f[call:1; len:4]1234
  93. f[call:2; len:4]5678
  94. f[call:3; len:0]
  95. ----( chunk_size: 5, output append size: 4 )----
  96. f[call:1; len:8]12345678
  97. f[call:2; len:0]
  98. ----( chunk_size: 6, output append size: 4 )----
  99. f[call:1; len:8]12345678
  100. f[call:2; len:0]
  101. ----( chunk_size: 7, output append size: 4 )----
  102. f[call:1; len:8]12345678
  103. f[call:2; len:0]
  104. ----( chunk_size: 8, output append size: 4 )----
  105. f[call:1; len:8]12345678
  106. f[call:2; len:0]
  107. ----( chunk_size: 9, output append size: 4 )----
  108. f[call:1; len:8]12345678