PHP/Utility Function/ob start — различия между версиями

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

Версия 10:37, 26 мая 2010

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(); ?>