PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ob_get_contents> <ob_flush
Last updated: Fri, 04 Jul 2008

view this page in

ob_get_clean

(PHP 4 >= 4.3.0, PHP 5)

ob_get_clean — Obtener los contenidos del búfer actual y eliminar el búfer de salida actual

Descripción

string ob_get_clean ( void )

Obtiene los contenidos del búfer actual y elimina el búfer de salida actual.

ob_get_clean() básicamente ejecuta tanto ob_get_contents() como ob_end_clean().

Valores retornados

Devuelve los contenidos del búfer de salida y finaliza el control de salida mediante búferes. Si el control de salida con búferes no está activo, entonces se devuelve FALSE.

Ejemplos

Example #1 Un ejemplo simple de ob_get_clean()

<?php

ob_start
();

echo 
"Hola Mundo";

$salida ob_get_clean();
$salida strtolower($salida);

var_dump($salida);
?>

El resultado del ejemplo seria:


string(10) "hola mundo"



ob_get_contents> <ob_flush
Last updated: Fri, 04 Jul 2008
 
add a note add a note User Contributed Notes
ob_get_clean
egbert teeselink
02-Feb-2008 04:47
If you're trying to capture the output from an included 3rd party script you don't seem to be capturing everything, the following might help:

function ob_end_clean_all()
{
    $s = "";
    do
    {
        $s = ob_get_contents() . $s;
    } while(ob_end_clean());
    return $s;
}

This function closes all nested output bufferings, therefore closing any buffers that the included script does not explicitly close. It's basically a ob_end_clean that sweeps together all the output buffers instead of just the innermost one.
ludvig dot ericson at gmail dot com
10-Aug-2005 04:10
Notice that the function beneath does not catch errors, so throw in an @ before those ob_* calls
webmaster at ragnarokonline dot de
02-Oct-2003 02:21
Running PHP4 < 4.3.0, you can simply add the following to use the function anyway:

<?php
if (!function_exists("ob_get_clean")) {
    function
ob_get_clean() {
       
$ob_contents = ob_get_contents();
       
ob_end_clean();
        return
$ob_contents;
    }
}
?>

ob_get_contents> <ob_flush
Last updated: Fri, 04 Jul 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites