PHP 8.5.0 Alpha 1 available for testing

ob_end_clean

(PHP 4, PHP 5, PHP 7, PHP 8)

ob_end_cleanElimina (limpia) el contenido del búfer de salida activo y lo desactiva.

Descripción

ob_end_clean(): bool

Esta función invoca al gestor de salida (con los flags PHP_OUTPUT_HANDLER_CLEAN y PHP_OUTPUT_HANDLER_FINAL), ignora su valor de retorno, ignora el contenido del búfer de salida activo y lo desactiva.

ob_end_clean() fallará sin un búfer de salida activo iniciado con el flag PHP_OUTPUT_HANDLER_REMOVABLE.

ob_end_clean() eliminará el contenido del búfer de salida activo incluso si fue iniciado sin el flag PHP_OUTPUT_HANDLER_CLEANABLE.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Devuelve true en caso de éxito o false en caso de error.

Errores/Excepciones

Si la función falla, genera una E_NOTICE.

Ejemplos

El siguiente ejemplo muestra una manera sencilla de deshacerse del contenido del búfer de salida activo:

Ejemplo #1 Ejemplo con ob_end_clean()

<?php
ob_start
();
echo
'Texto que no será mostrado.';
ob_end_clean();
?>

Ver también

  • ob_start() - Activa el temporizador de salida
  • ob_get_contents() - Devuelve el contenido del búfer de salida
  • ob_clean() - Limpiar (borrar) el contenido del búfer de salida activo.
  • ob_get_clean() - Obtiene 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

add a note

User Contributed Notes 2 notes

up
7
John Smith
21 years ago
Note that if you started called ob_start with a callback, that callback will still be called even if you discard the OB with ob_end_clean.

Because there is no way of removing the callback from the OB once you've set it, the only way to stop the callback function from having any effect is to do something like:

<?php
$ignore_callback
= false;
ob_start('my_callback');
...
if(
$need_to_abort) {
$ignore_callback = true;
ob_end_clean();
...
}

function
my_callback(&$buffer) {
if(
$GLOBALS['ignore_callback']) {
return
"";
}
...
}
?>
up
7
Sam Yong - hellclanner at live dot com
14 years ago
Take note that if you change zlib output compression setting in between ob_start and ob_end_clean or ob_end_flush, you will get an error: ob_end_flush() failed to delete buffer zlib output compression

Example:

<?php

ob_start
();

$output = ob_get_contents();

ini_set('zlib.output_compression', '1');

ob_end_clean();

?>

ob_end_clean(); in this example will throw the error.
To Top