已经发送的标题 [英] Headers already sent by

查看:82
本文介绍了已经发送的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误:



警告:无法修改标头信息 - 已经发送的标头(输出从C:\ xampp \ htdocs \\开始\ index.php:123)在第145行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ >
[PHP] a - Pastebin.com [ ^ ]



我的尝试:



我尝试了我的想法,但我做不到。

I'm getting this error:

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\index.php:123) in C:\xampp\htdocs\sayfalar\detay.php on line 145

And my code:
[PHP] a - Pastebin.com[^]

What I have tried:

I tried what I thought but I can't do.

推荐答案

你只需要了解标题是什么以及什么HTTP响应是。所有PHP都是创建此响应。标题永远是第一位的。所有HTTP响应内容都是按顺序自上而下写入的,没有可能返回;但是,您可以使用 header_remove 修改标题信息。



所以,想象一下如果你回应一些数据会发生什么。这意味着编写任何标题为时已晚,此步骤已经过去了。一些标题是隐式写的;当您回显一些数据并且没有写入标题时,首先输出所需的标题,然后输入您回显的数据。最有可能的是,你在尝试添加/修改标题之前创建了一些输出。



如果你需要编写自定义标题,那么应该在你开始时完成PHP执行流程(不一定是PHP代码的第一行,你可以在其中有一些声明);在编写标题之前,不要回显任何内容是很重要的。一旦你在HTTP响应体中创建了一些输出,添加或修改标题就太晚了。



参见:

PHP:标题 - 手册 [ ^ ],

如何修复& quot;已经发送的标题& quot; PHP中的错误 - 堆栈溢出 [ ^ ]。



-SA
You just need to understand what headers are and what HTTP response is. All PHP does is the creation of this response. And headers always come first. All the HTTP response content is written sequentially, top down, without a possibility to get back; however, you can, say, modify header information with header_remove.

So, imagine what happens if you echo some data. It means that it's too late to write any header, this step is already passed. Some headers are written implicitly; when you echo some data, and no headers are written, required headers are output first, and then goes the data you echo. Most likely, you created some output before trying to add/modify headers.

If you need to write your custom headers, it should be done in the very beginning of your PHP execution flow (that is not necessarily in first lines of PHP code, where you can have some declarations); it's important that you don't echo anything before you write headers. As soon as you created some output in the body of HTTP response, it's too late to add or modify headers.

See also:
PHP: header — Manual[^],
How to fix "Headers already sent" error in PHP — Stack Overflow[^].

—SA


尝试检查代码中的空格,删除不必要的空格



Try Checking your code for spaces, remove unnecessary spaces here

<?php include("fonksiyonlar/config.php"); ?>

<?php


id =


这篇关于已经发送的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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