รูปแบบ header
void header ( string string [, bool replace [, int http_response_code]] )
เป็น function ที่ทำหน้าที่ บอก browser ว่า เรากำลังจะส่ง output เป็น อะไร ออกไปให้ ผ่าน ทาง http
รูปแบบ ของ string ที่เรา จะใช้มีเยอะมากๆ ใครมีคำถาม หรือข้อสงสัยโพสไว้ได้ ที่บอร์ด นะครับ
ตัวอย่างการนำไปประยุกต์ใช้
<?php
header("Location: http://www.example.com/"); /* Redirect browser */
exit;
?>
ตัวอย่าง
เมือเราใช่ header แล้ว http ที่ส่งไปยัง browser ก็จะเป็นไปตามที่ได้กำหนัดเอาไว้

หรือจะสงผล ออกเป็น pdf ก็ทำได้เช่น
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
?>
หรือจะหน่วงเวลาก่อนจะไปหน้าเว็บจริง ๆ
header("Refresh: เวลาเป็นวินาที; url=เพจปลายทาง");
หรือจะ refresh หน้านั้นซ้ำ ๆ
header("Refresh: เวลาเป็นวินาที");