PHP 8.5.0 Alpha 1 available for testing

Funciones del Control de la salida

Ver también

Véase también header() y setcookie().

Tabla de contenidos

  • flush — Vacía los búferes de salida del sistema
  • ob_clean — Limpiar (borrar) el contenido del búfer de salida activo.
  • ob_end_clean — Elimina (limpia) el contenido del búfer de salida activo y lo desactiva.
  • ob_end_flush — Vacía (envía) el valor de retorno del manejador de salida activo y desactiva el búfer de salida activo
  • ob_flush — Vacía (envía) el valor de retorno del manejador de salida activo.
  • ob_get_clean — Obtiene el contenido del búfer de salida activo y lo desactiva
  • ob_get_contents — Devuelve el contenido del búfer de salida
  • ob_get_flush — Vacía (envía) el valor de retorno del gestor de salida activo, devuelve el contenido del búfer de salida activo y lo desactiva.
  • ob_get_length — Devuelve la longitud del contenido del búfer de salida
  • ob_get_level — Devuelve el número de niveles de anidación del sistema de temporización de salida
  • ob_get_status — Lee el estado del búfer de salida
  • ob_implicit_flush — Activa/desactiva el envío implícito
  • ob_list_handlers — Lista los gestores de salida utilizados
  • ob_start — Activa el temporizador de salida
  • output_add_rewrite_var — Añade una regla de reescritura de URL
  • output_reset_rewrite_vars — Anula la reescritura de URL
add a note

User Contributed Notes 3 notes

up
18
jgeewax a t gmail
18 years ago
It seems that while using output buffering, an included file which calls die() before the output buffer is closed is flushed rather than cleaned. That is, ob_end_flush() is called by default.

<?php
// a.php (this file should never display anything)
ob_start();
include(
'b.php');
ob_end_clean();
?>

<?php
// b.php
print "b";
die();
?>

This ends up printing "b" rather than nothing as ob_end_flush() is called instead of ob_end_clean(). That is, die() flushes the buffer rather than cleans it. This took me a while to determine what was causing the flush, so I thought I'd share.
up
4
Anonymous
16 years ago
You possibly also want to end your benchmark after the output is flushed.

<?php
your_benchmark_start_function
();

ob_start ();
for (
$i = 0; $i < 5000; $i++)
echo
str_repeat ("your string blablabla bla bla", (rand() % 4) + 1)."<br>\n";

<----------
echo
your_benchmark_end_function(); |
ob_end_flush (); ------------------------
?>
up
4
gruik at libertysurf dot fr
20 years ago
For those who are looking for optimization, try using buffered output.

I noticed that an output function call (i.e echo()) is somehow time expensive. When using buffered output, only one output function call is made and it seems to be much faster.
Try this :

<?php
your_benchmark_start_function
();

for (
$i = 0; $i < 5000; $i++)
echo
str_repeat ("your string blablabla bla bla", (rand() % 4) + 1)."<br>\n";

echo
your_benchmark_end_function();
?>

And then :

<?php
your_benchmark_start_function
();

ob_start ();
for (
$i = 0; $i < 5000; $i++)
echo
str_repeat ("your string blablabla bla bla", (rand() % 4) + 1)."<br>\n";

echo
your_benchmark_end_function();
ob_end_flush ();
?>
To Top