PHP错误:警告:无法修改标题信息 - 已发送的标题 [英] PHP error: Warning: Cannot modify header information - headers already sent by

查看:922
本文介绍了PHP错误:警告:无法修改标题信息 - 已发送的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PHP中写下一个简单的邮件脚本

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...

错误说:输出开始于/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\nZender: $firstName $lastName\nBericht: $message", "From: $email");
header("Location:http://www.....com");  
exit;
?>


推荐答案

发送头之前没有输出



发出/修改HTTP头的功能必须在任何输出作出之前调用。否则调用失败:

No output before sending headers

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


警告:无法修改头信息 - 已发送的头文件(输出以文件:line

修改HTTP标头的一些功能是:

Some functions modifying the HTTP header are:

  • header / header_remove
  • session_start / session_regenerate_id
  • setcookie / setrawcookie

输出可以是:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆