Re: [請益] 前往頁面的問題

看板PHP作者 (每天都在公司玩OLG)時間17年前 (2008/07/26 01:54), 編輯推噓4(407)
留言11則, 3人參與, 最新討論串2/4 (看更多)
<?php require_once("./phpmailer/class.phpmailer.php"); $mail=new PHPMailer(); $mail->IsSMTP(); $mail->Host="msa.hinet.net"; $mail->Fromm=''; $mail->FromName='阿'; $mail->AddAddress('xxxx'); $mail->CharSet='utf-8'; $mail->ContentType="text/html"; $mail->Subject='系統公告'; $mail->Body='已新增一項留言'; if ($mail->Send()) { header('Location: index.php'); } else { ?> <html> <head> <title>TITLE</title> </head> <body> fail! </body> </html> <?php } ?> 有錯誤再來 output HTML 頁面....... -- Linux is for people who want to know why it works. Mac is for people who don't want to know why it works. DOS is for people who want to know why it does not work. Windows is for people who don't want to know why it does not work. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.173.168.127

07/26 02:15, , 1F
多謝回答,我想問一下如果在<html>上已完成,那body
07/26 02:15, 1F

07/26 02:15, , 2F
還會被執行嗎?
07/26 02:15, 2F

07/26 02:18, , 3F
你可以在 header() 下面加上 exit() 解除你的疑慮
07/26 02:18, 3F

07/26 02:46, , 4F
簡單說,header 是產生一些資料給 Client 看,並沒有
07/26 02:46, 4F

07/26 02:47, , 5F
Server 自己想跳往哪個網頁這種 JUMP 指令;如果有
07/26 02:47, 5F

07/26 02:47, , 6F
JUMP,那也不必 exit 了;header 給 Client 看,exit 給
07/26 02:47, 6F

07/26 02:48, , 7F
Server 看;而 Client 看了特定 header 是會想JUMP..
07/26 02:48, 7F

07/26 02:48, , 8F
廣義的說,setcookie 也動手腳在 header;而 header 名
07/26 02:48, 8F

07/26 02:49, , 9F
為 header,所以在其上就不能先有其他資料
07/26 02:49, 9F

07/26 02:51, , 10F
可參照這篇 http://0rz.tw/ec4uz 良好的習慣是重要的
07/26 02:51, 10F

07/26 08:13, , 11F
那個網址正好在爭論題目 XD
07/26 08:13, 11F
文章代碼(AID): #18YXD0B6 (PHP)
文章代碼(AID): #18YXD0B6 (PHP)