array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'es', ), 'this' => array ( 0 => 'function.ob-get-contents.php', 1 => 'ob_get_contents', ), 'up' => array ( 0 => 'ref.outcontrol.php', 1 => 'Funciones del Control de la salida', ), 'prev' => array ( 0 => 'function.ob-get-clean.php', 1 => 'ob_get_clean', ), 'next' => array ( 0 => 'function.ob-get-flush.php', 1 => 'ob_get_flush', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'es', 'path' => 'reference/outcontrol/functions/ob-get-contents.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
ob_get_contents — Devolver el contenido del búfer de salida
Devolverá el contenido del búfer de salida, o false
si el almacenameinto
en el búfer de salida no está activo.
Ejemplo #1 Un ejemplo sencillo de ob_get_contents()
<?php
ob_start();
echo "Hola ";
$salida1 = ob_get_contents();
echo "Mundo";
$salida2 = ob_get_contents();
ob_end_clean();
var_dump($salida1, $salida2);
?>
El resultado del ejemplo sería:
string(5) "Hola " string(10) "Hola Mundo"