File: outcontrol.xml

package info (click to toggle)
phpdoc 20020310-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 35,272 kB
  • ctags: 354
  • sloc: xml: 799,767; php: 1,395; cpp: 500; makefile: 200; sh: 140; awk: 51
file content (393 lines) | stat: -rw-r--r-- 11,927 bytes parent folder | download
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<?xml version="1.0" encoding="utf-8"?>
 <reference id="ref.outcontrol">
  <title>Output Control Functions</title>
  <titleabbrev>Output Control</titleabbrev>

  <partintro>
   <para>
    The Output Control functions allow you to control when output is
    sent from the script.  This can be useful in several different
    situations, especially if you need to send headers to the browser
    after your script has began outputing data.  The Output Control
    functions do not affect headers sent using
    <function>header</function> or <function>setcookie</function>,
    only functions such as <function>echo</function> and data between
    blocks of PHP code.
   </para>
   <para>
    <example>
     <title>Output Control example</title>
     <programlisting role="php">
&lt;?php

ob_start();
echo "Hello\n";

setcookie ("cookiename", "cookiedata");

ob_end_flush();

?&gt;
     </programlisting>
    </example>
   </para>
   <para>
    In the above example, the output from <function>echo</function>
    would be stored in the output buffer until
    <function>ob_end_flush</function> was called.  In the mean time,
    the call to <function>setcookie</function> successfully stored a
    cookie without causing an error. (You can not normally send
    headers to the browser after data has already been sent.)
   </para>
   <para>
    See also <function>header</function> and
    <function>setcookie</function>.
   </para>
  </partintro>

  <refentry id="function.flush">
   <refnamediv>
    <refname>flush</refname> 
    <refpurpose>Flush the output buffer</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>void</type><methodname>flush</methodname>
      <void/>
     </methodsynopsis>
    <simpara>
     Flushes the output buffers of PHP and whatever backend PHP is
     using (CGI, a web server, etc.)  This effectively tries to push
     all the output so far to the user's browser.
    </simpara>
		<note>
		 <para>
			<function>flush</function> has no effect on the buffering
			 scheme of your webserver or the browser on the client
			 side. 
		 </para>
		 <para>
			Several servers, especially on Win32, will still buffer
			the output from your script until it terminates before
			transmitting the results to the browser. 
		 </para>
		 <para>
			Even the browser may buffer its input before displaying it. 
			Netscape, for example, buffers text until it receives an
			end-of-line or the beginning of a tag, and it won't render
			tables until the &lt;/table&gt; tag of the outermost table is
			seen.
		 </para>
		</note>
   </refsect1>
  </refentry>

  <refentry id="function.ob-start">
   <refnamediv>
    <refname>ob_start</refname> 
    <refpurpose>Turn on output buffering</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>void</type><methodname>ob_start</methodname>
      <methodparam choice="opt"><type>string</type><parameter>
        output_callback
       </parameter></methodparam>
     </methodsynopsis>
    <para>
     This function will turn output buffering on. While output
     buffering is active no output is sent from the script (other than
     headers), instead the output is stored in an internal buffer.
    </para>
    <para>
     The contents of this internal buffer may be copied into a string
     variable using <function>ob_get_contents</function>.  To output
     what is stored in the internal buffer, use
     <function>ob_end_flush</function>.  Alternatively,
     <function>ob_end_clean</function> will silently discard the
     buffer contents.
    </para>
    <para>
     An optional <parameter>output_callback</parameter> function may
     be specified. This function takes a string as a parameter and
     should return a string. The function will be called when
     <function>ob_end_flush</function> is called, or when the output
     buffer is flushed to the browser at the end of the request.  When
     <parameter>output_callback</parameter> is called, it will receive
     the contents of the output buffer as its parameter and is
     expected to return a new output buffer as a result, which will be
     sent to the browser.
    </para>
    <note>
     <para>
      In PHP 4.0.4, <function>ob_gzhandler</function> was introduced
      to facilitate sending gz-encoded data to web browsers that
      support compressed web pages.  <function>ob_gzhandler</function>
      determines what type of content encoding the browser will accept
      and will return it's output accordingly.
     </para>
    </note>
    <para>
     Output buffers are stackable, that is, you may call
     <function>ob_start</function> while another
     <function>ob_start</function> is active. Just make
     sure that you call <function>ob_end_flush</function>
     the appropriate number of times. If multiple output callback
     functions are active, output is being filtered sequentially
     through each of them in nesting order.
    </para>
    <example>
     <title>User defined callback function example</title>
     <programlisting role="php">
&lt;?php

function callback($buffer) {

  // replace all the apples with oranges
  return (ereg_replace("apples", "oranges", $buffer));

}

ob_start("callback");

?&gt;

&lt;html&gt;
&lt;body&gt;
&lt;p&gt;It's like comparing apples to oranges.
&lt;/body&gt;
&lt;/html&gt;

&lt;?php

ob_end_flush();

?&gt;
     </programlisting>
    </example>
    <para>
     Would produce:
     <informalexample>
      <programlisting role="php">
&lt;html&gt;
&lt;body&gt;
&lt;p&gt;It's like comparing oranges to oranges.
&lt;/body&gt;
&lt;/html&gt;
      </programlisting>
     </informalexample>
    </para>
    <para>
     See also <function>ob_get_contents</function>,
     <function>ob_end_flush</function>,
     <function>ob_end_clean</function>,
     <function>ob_implicit_flush</function> and
     <function>ob_gzhandler</function>.
    </para>
   </refsect1>
  </refentry>
 
  <refentry id="function.ob-get-contents">
   <refnamediv>
    <refname>ob_get_contents</refname> 
    <refpurpose>
     Return the contents of the output buffer
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>ob_get_contents</methodname>
      <void/>
     </methodsynopsis>
    <para>
     This will return the contents of the output buffer or &false;, if
     output buffering isn't active.
    </para>
    <para>
     See also <function>ob_start</function> and
     <function>ob_get_length</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.ob-get-length">
   <refnamediv>
    <refname>ob_get_length</refname>
    <refpurpose>
     Return the length of the output buffer
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>ob_get_length</methodname>
      <void/>
     </methodsynopsis>
    <para>
     This will return the length of the contents in the output buffer
     or &false;, if output buffering isnt't active.
    </para>
    <para>
     See also <function>ob_start</function> and
     <function>ob_get_contents</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.ob-gzhandler">
   <refnamediv>
    <refname>ob_gzhandler</refname>
    <refpurpose>
     ob_start callback function to gzip output buffer
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>ob_gzhandler</methodname>
      <methodparam><type>string</type><parameter>buffer</parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>ob_gzhandler</function> is intended to be used as a
     callback function for <function>ob_start</function> to help
     facilitate sending gz-encoded data to web browsers that support
     compressed web pages.  Before <function>ob_gzhandler</function>
     actually sends compressed data, it determines what type of
     content encoding the browser will accept ("gzip", "deflate" or
     none at all) and will return it's output accordingly.  All
     browsers are supported since it's up to the browser to send the
     correct header saying that it accepts compressed web pages.
    </para>
    <para>
     <example>
      <title><function>ob_gzhandler</function> Example</title>
      <programlisting role="php">
&lt;php

ob_start("ob_gzhandler");

?>
&lt;html&gt;
&lt;body&gt;
&lt;p&gt;This should be a compressed page.
&lt;/html&gt;
&lt;/body&gt;
      </programlisting>
     </example>
    </para>
    <para>
     See also <function>ob_start</function> and
     <function>ob_end_flush</function>.
    </para>
   </refsect1>
  </refentry>
 
  <refentry id="function.ob-end-flush">
   <refnamediv>
    <refname>ob_end_flush</refname> 
    <refpurpose>
     Flush (send) the output buffer and turn off output buffering    
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>void</type><methodname>ob_end_flush</methodname>
      <void/>
     </methodsynopsis>
    <para>
     This function will send the contents of the output buffer (if
     any) and turn output buffering off.  If you want to further
     process the buffer's contents you have to call
     <function>ob_get_contents</function> before
     <function>ob_end_flush</function> as the buffer contents are
     discarded after <function>ob_end_flush</function> is called.
    </para>
    <para>
     See also <function>ob_start</function>,
     <function>ob_get_contents</function>, and
     <function>ob_end_clean</function>.
    </para>
   </refsect1>
  </refentry>
 
  <refentry id="function.ob-end-clean">
   <refnamediv>
    <refname>ob_end_clean</refname> 
    <refpurpose>
     Clean (erase) the output buffer and turn off output buffering
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>void</type><methodname>ob_end_clean</methodname>
      <void/>
     </methodsynopsis>
    <para>
     This function discards the contents of the output buffer and
     turns off output buffering.
    </para>
    <para>
     See also <function>ob_start</function> and
     <function>ob_end_flush</function>.
    </para>
   </refsect1>
  </refentry>
 
  <refentry id="function.ob-implicit-flush">
   <refnamediv>
    <refname>ob_implicit_flush</refname> 
    <refpurpose>
     Turn implicit flush on/off 
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>void</type><methodname>ob_implicit_flush</methodname>
      <methodparam choice="opt"><type>int</type><parameter>flag</parameter></methodparam>		  
     </methodsynopsis>
    <para>
     <function>ob_implicit_flush</function> will turn implicit
     flushing on or off (if no <parameter>flag</parameter> is given,
     it defaults to on).  Implicit flushing will result in a flush
     operation after every output call, so that explicit calls to
     <function>flush</function> will no longer be needed.
    </para>
    <para>
     Turning implicit flushing on will disable output buffering, the
     output buffers current output will be sent as if
     <function>ob_end_flush</function> had been called.
    </para>
    <para>
     See also <function>flush</function>,
     <function>ob_start</function>, and
     <function>ob_end_flush</function>.
    </para>
   </refsect1>
  </refentry>

 </reference>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->