PHP/Utility Function/ob start

Материал из Web эксперт
Перейти к: навигация, поиск

Buffering output

 
<?php ob_start(); ?>
I haven"t decided if I want to send a cookie yet.
<?php setcookie("heron","great blue"); ?>
Yes, sending that cookie was the right decision.
<?php ob_end_flush(); ?>



Using a callback with ob_start()

 
<?php 
function mangle_email($s) {
    return preg_replace("/([^@\s]+)@([-a-z0-9]+\.)+[a-z]{2,}/is",
                        "<$1@...>",
                        $s);
}
ob_start("mangle_email"); 
?>
I would not like spam sent to ronald@example.ru!
<?php ob_end_flush(); ?>