doumeilmikv7099 2014-02-07 02:11
浏览 85
已采纳

PHP错误:警告:无法修改标头信息 - 已由[重复]发送的标头

This question already has an answer here:

Hi I'm wrinting a simple mail script in PHP

  • Of what that I found every one says its probably a whitespace in front of

But as you can see I can't find anything like the solutions on the internet in my code...

The error says : output started at /customers/e/e/5//httpd.www/email.php:1)

<?php
$to = '...@gmail.com';
$subject = $_POST['subject'];  
$message = $_POST['message'];  
$firstName = $_POST['firstName'];  
$lastName = $_POST['lastName'];  
$email = $_POST['email'];  
mail($to, "Contact www....com: $subject", "Gecontacteerd van de website: www.....com
Zender: $firstName $lastName
Bericht: $message", "From: $email");
header("Location:http://www.....com");  
exit;
?>
</div>
  • 写回答

2条回答 默认 最新

  • doudiecai1572 2014-02-07 02:11
    关注

    No output before sending headers

    Functions that send/modify HTTP headers must be invoked before any output is made. Otherwise the call fails:

    Warning: Cannot modify header information - headers already sent (output started at file:line)

    Some functions modifying the HTTP header are:

    Output can be:

    • Unintentional:
    • Intentional:
      • print, echo and other functions producing output (like var_dump)
      • Raw <html> areas before <?php code.

    Hint : for checking this, press crtl+u on the page to see the source, and check if the error is in line 2 , or there is a space before it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部