สามารถนำไปประยุกต์ในการส่งอีเมลล์แบบ HTML ได้
ตัวอย่างโค้ด
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php function callback( $buffer ) { return $buffer ; } ob_start( "callback" ); // ตำแหน่งเริ่มต้น ?> <html> <head> <title>เก็บ HTML ไว้ในตัวแปร PHP</title> <style type= "text/css" > ..mysty1{ width:150px; height:200px; background-color:#FFCC66; } </style> </head> <body> <div class = "mysty1" > </div> </body> </html> <?php $save_data =ob_get_contents(); // เก็บ HTML ไว้ในตัวแปร ob_end_flush(); // ตำแหน่งสิ้นสุด // เราสามารถ echo ค่าของ $save_date และจะำได้เป็น HTML ที่เก็บไว้ ?> |