1--TEST-- 2ob_start() chunk_size: confirm buffer is flushed after any output call that causes its length to equal or exceed chunk_size. 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 10function callback($string) { 11 global $callback_invocations; 12 $callback_invocations++; 13 $len = strlen($string); 14 return "f[call:$callback_invocations; len:$len]$string\n"; 15} 16 17for ($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 25for ($cs=-1; $cs<10; $cs++) { 26 echo "\n----( chunk_size: $cs, output append size: 4 )----\n"; 27 $callback_invocations=0; 28 ob_start('callback', $cs); 29 echo '1234'; echo '5678'; 30 ob_end_flush(); 31} 32 33?> 34--EXPECTF-- 35 36----( chunk_size: -1, output append size: 1 )---- 37f[call:1; len:8]12345678 38 39----( chunk_size: 0, output append size: 1 )---- 40f[call:1; len:8]12345678 41 42----( chunk_size: 1, output append size: 1 )---- 43f[call:1; len:8]12345678 44 45----( chunk_size: 2, output append size: 1 )---- 46f[call:1; len:2]12 47f[call:2; len:2]34 48f[call:3; len:2]56 49f[call:4; len:2]78 50f[call:5; len:0] 51 52----( chunk_size: 3, output append size: 1 )---- 53f[call:1; len:3]123 54f[call:2; len:3]456 55f[call:3; len:2]78 56 57----( chunk_size: 4, output append size: 1 )---- 58f[call:1; len:4]1234 59f[call:2; len:4]5678 60f[call:3; len:0] 61 62----( chunk_size: 5, output append size: 1 )---- 63f[call:1; len:5]12345 64f[call:2; len:3]678 65 66----( chunk_size: 6, output append size: 1 )---- 67f[call:1; len:6]123456 68f[call:2; len:2]78 69 70----( chunk_size: 7, output append size: 1 )---- 71f[call:1; len:7]1234567 72f[call:2; len:1]8 73 74----( chunk_size: 8, output append size: 1 )---- 75f[call:1; len:8]12345678 76f[call:2; len:0] 77 78----( chunk_size: 9, output append size: 1 )---- 79f[call:1; len:8]12345678 80 81----( chunk_size: -1, output append size: 4 )---- 82f[call:1; len:8]12345678 83 84----( chunk_size: 0, output append size: 4 )---- 85f[call:1; len:8]12345678 86 87----( chunk_size: 1, output append size: 4 )---- 88f[call:1; len:8]12345678 89 90----( chunk_size: 2, output append size: 4 )---- 91f[call:1; len:4]1234 92f[call:2; len:4]5678 93f[call:3; len:0] 94 95----( chunk_size: 3, output append size: 4 )---- 96f[call:1; len:4]1234 97f[call:2; len:4]5678 98f[call:3; len:0] 99 100----( chunk_size: 4, output append size: 4 )---- 101f[call:1; len:4]1234 102f[call:2; len:4]5678 103f[call:3; len:0] 104 105----( chunk_size: 5, output append size: 4 )---- 106f[call:1; len:8]12345678 107f[call:2; len:0] 108 109----( chunk_size: 6, output append size: 4 )---- 110f[call:1; len:8]12345678 111f[call:2; len:0] 112 113----( chunk_size: 7, output append size: 4 )---- 114f[call:1; len:8]12345678 115f[call:2; len:0] 116 117----( chunk_size: 8, output append size: 4 )---- 118f[call:1; len:8]12345678 119f[call:2; len:0] 120 121----( chunk_size: 9, output append size: 4 )---- 122f[call:1; len:8]12345678