无法在PHP中修改标题信息警告消息? [英] Cannot modify header information Warning message in PHP?

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

问题描述

我的 index.php 页码是 -

<?php

if(!$_COOKIE['authorized'] == 1) {
header("Location: login.php");
}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org   /TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Photo Website</title>
<script src="js/jquery-1.2.6.pack.js" type="text/javascript"></script>
<script src="js/jquery.lightbox-0.5.pack.js" type="text/javascript"></script>
<script src="js/myscript.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/default.css" />
<link rel="stylesheet" href="css/jquery.lightbox-0.5.css" />


</head>
<body>
<form method="post" action="changePhotoTitle.php">
<div id="container">
<h1>My Photos <small>click on the text to change the title.</small></h1>
<a href="login.php?logout=1" id="logout">logout</a>

<div id="main">

<?php require 'getPhotos.php'; ?>

<div id="response" class="hidden" />
</div><!-- end main-->

</div><!-- end container-->
</form>
</body>
</html>

我的database.php页面代码是 -

<?php

$db_name = "db";
$db_server = "localhost";
$db_user = "root";
$db_pass = "";

$mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error());

?>

但随后出现警告信息 -
警告:无法修改标题信息 - 已在第4行的C:\ xampp \ htdocs \ pics \ index.php中发送的输出(输出从C:\ xampp \ htdocs \ pics \ index.php:1开始)

but followong warning message is coming- Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\pics\index.php:1) in C:\xampp\htdocs\pics\index.php on line 4

推荐答案

从维基百科条目中引用BOM:

Quoting from the Wikipedia entry for BOM:


字节顺序标记

许多Windows程序(包括
Windows记事本)添加字节0xEF,$ b保存为UTF-8的任何
文档开头的$ b 0xBB,0xBF。这是Unicode字节
订单标记(BOM)的
UTF-8编码,通常是
,称为UTF-8 BOM,即使
不相关到字节顺序。如果带有BOM的另一个
编码转换为
UTF-8而不剥离它,也会出现
BOM。

Many Windows programs (including Windows Notepad) add the bytes 0xEF, 0xBB, 0xBF at the start of any document saved as UTF-8. This is the UTF-8 encoding of the Unicode byte order mark (BOM), and is commonly referred to as a UTF-8 BOM even though it is not relevant to byte order. The BOM can also appear if another encoding with a BOM is translated to UTF-8 without stripping it.

存在UTF-8 BOM可能会导致
现有软件的互操作性问题,否则可以处理UTF-8,例如:

The presence of the UTF-8 BOM may cause interoperability problems with existing software that could otherwise handle UTF-8, for example:

+ 较旧的文本编辑器可能会在文档的开头显示BOM作为,即使UTF-8文件仅包含ASCII,否则将正确显示。

+ 编程语言解析器通常可以在字符串常量和注释中处理UTF-8,但无法解析文件开头的BOM。

+ Older text editors may display the BOM as "" at the start of the document, even if the UTF-8 file contains only ASCII and would otherwise display correctly.
+ Programming language parsers can often handle UTF-8 in string constants and comments, but cannot parse the BOM at the start of the file.

这篇关于无法在PHP中修改标题信息警告消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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