[PHP note] - ข้อเสียของการใช้ฟังชั่น header();

Warning: Cannot modify header information - headers already sent by (output started at


ตัวอย่างการใช้ ฟังชั่น header(); ในการ refresh หน้าเว็บให้ redirect ไปยังหน้าอื่น
เช่น  header('refresh:3; url=/path/file.php');

หากมีการ echo 
หรือมี <html> อยู่ก่อน ก็ทำให้ error ได้แล้ว

ให้เปลี่ยนไปใช้แบบนี้แทน
echo '<meta http-equiv="refresh" content="3; url=/path/file.php">';