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

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 10: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条)

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器