PHP/Utility Function/ob start

Материал из Web эксперт
Версия от 10:07, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Buffering output

   <source lang="html4strict">

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

 </source>
   
  


Using a callback with ob_start()

   <source lang="html4strict">

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

 </source>