File: ob_start_basic_004.phpt

package info (click to toggle)
php5 5.3.3-7%2Bsqueeze19
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 122,836 kB
  • ctags: 55,742
  • sloc: ansic: 633,963; php: 19,620; sh: 11,344; xml: 5,816; cpp: 2,400; yacc: 1,745; exp: 1,514; makefile: 1,019; pascal: 623; awk: 537; sql: 22
file content (122 lines) | stat: -rw-r--r-- 2,958 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
--TEST--
ob_start() chunk_size: confirm buffer is flushed after any output call that causes its length to equal or exceed chunk_size.
--FILE--
<?php
/* 
 * proto bool ob_start([ string|array user_function [, int chunk_size [, bool erase]]])
 * Function is implemented in main/output.c
*/ 

function callback($string) {
	global $callback_invocations;
	$callback_invocations++;
	$len = strlen($string);
	return "f[call:$callback_invocations; len:$len]$string\n";
}

for ($cs=-1; $cs<10; $cs++) {
  echo "\n----( chunk_size: $cs, output append size: 1 )----\n";
  $callback_invocations=0;
  ob_start('callback', $cs);
  echo '1'; echo '2'; echo '3'; echo '4'; echo '5'; echo '6'; echo '7'; echo '8';
  ob_end_flush();
}

for ($cs=-1; $cs<10; $cs++) {
  echo "\n----( chunk_size: $cs, output append size: 4 )----\n";
  $callback_invocations=0;
  ob_start('callback', $cs);
  echo '1234'; echo '5678';
  ob_end_flush();
}

?>
--EXPECTF--

----( chunk_size: -1, output append size: 1 )----
f[call:1; len:8]12345678

----( chunk_size: 0, output append size: 1 )----
f[call:1; len:8]12345678

----( chunk_size: 1, output append size: 1 )----
f[call:1; len:8]12345678

----( chunk_size: 2, output append size: 1 )----
f[call:1; len:2]12
f[call:2; len:2]34
f[call:3; len:2]56
f[call:4; len:2]78
f[call:5; len:0]

----( chunk_size: 3, output append size: 1 )----
f[call:1; len:3]123
f[call:2; len:3]456
f[call:3; len:2]78

----( chunk_size: 4, output append size: 1 )----
f[call:1; len:4]1234
f[call:2; len:4]5678
f[call:3; len:0]

----( chunk_size: 5, output append size: 1 )----
f[call:1; len:5]12345
f[call:2; len:3]678

----( chunk_size: 6, output append size: 1 )----
f[call:1; len:6]123456
f[call:2; len:2]78

----( chunk_size: 7, output append size: 1 )----
f[call:1; len:7]1234567
f[call:2; len:1]8

----( chunk_size: 8, output append size: 1 )----
f[call:1; len:8]12345678
f[call:2; len:0]

----( chunk_size: 9, output append size: 1 )----
f[call:1; len:8]12345678

----( chunk_size: -1, output append size: 4 )----
f[call:1; len:8]12345678

----( chunk_size: 0, output append size: 4 )----
f[call:1; len:8]12345678

----( chunk_size: 1, output append size: 4 )----
f[call:1; len:8]12345678

----( chunk_size: 2, output append size: 4 )----
f[call:1; len:4]1234
f[call:2; len:4]5678
f[call:3; len:0]

----( chunk_size: 3, output append size: 4 )----
f[call:1; len:4]1234
f[call:2; len:4]5678
f[call:3; len:0]

----( chunk_size: 4, output append size: 4 )----
f[call:1; len:4]1234
f[call:2; len:4]5678
f[call:3; len:0]

----( chunk_size: 5, output append size: 4 )----
f[call:1; len:8]12345678
f[call:2; len:0]

----( chunk_size: 6, output append size: 4 )----
f[call:1; len:8]12345678
f[call:2; len:0]

----( chunk_size: 7, output append size: 4 )----
f[call:1; len:8]12345678
f[call:2; len:0]

----( chunk_size: 8, output append size: 4 )----
f[call:1; len:8]12345678
f[call:2; len:0]

----( chunk_size: 9, output append size: 4 )----
f[call:1; len:8]12345678