PHP错误:警告:无法修改标题信息 - 已发送的标题 [英] PHP error: Warning: Cannot modify header information - headers already sent by
本文介绍了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
输出可以是:
- 无意的:
-
<?php
或
?>之后;
- UTF-8字节订单标记
- 以前的错误消息或通知
- Unintentional:
- Whitespace before
<?php
or after?>
- UTF-8 Byte Order Mark
- Previous error messages or notices
-
print
,echo
等产生输出的函数(如var_dump
) - 原始
< html>
<?php
代码。
print
,echo
and other functions producing output (likevar_dump
)- Raw
<html>
areas before<?php
code.
提示: strong> crtl + u 查看源代码,并检查错误是否在第二行,或之前有空格。
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.
这篇关于PHP错误:警告:无法修改标题信息 - 已发送的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Whitespace before
-
查看全文