Reference - What does this error mean in PHP?
P粉478445671
P粉478445671 2023-08-27 15:07:53
0
1
396
<p><br /></p><h3>这是什么?</h3> <p>这是一些关于您在 PHP 编程时可能遇到的警告、错误和通知的答案,但不知道如何修复它们。这也是一个社区 Wiki,因此邀请每个人参与添加和维护此列表。</p> <h3>这是为什么?</h3> <p>诸如“标头已发送”或“调用非对象的成员”之类的问题经常出现在 Stack Overflow 上。这些问题的根本原因总是相同的。因此,这些问题的答案通常会重复它们,然后向操作员展示在特定情况下要更改哪一行。这些答案不会给网站增加任何价值,因为它们仅适用于 OP 的特定代码。其他有相同错误的用户无法轻松地从中读出解决方案,因为它们太本地化了。这是可悲的,因为一旦你了解了根本原因,修复错误就变得微不足道了。因此,此列表试图以通用的应用方式解释该解决方案。</p> <h3>我应该在这里做什么?</h3> <p>如果您的问题已被标记为与此问题重复,请在下面找到您的错误消息并将修复应用于您的代码。答案通常包含进一步调查的链接,以防仅从一般答案中不清楚。</p> <p>如果您想做出贡献,请添加您“最喜欢的”错误消息、警告或通知,每个答案一个,简短描述其含义(即使只是在其手册页中突出显示术语),可能的解决方案或调试方法以及有价值的现有问答列表。另外,请随意改进任何现有答案。</p> <h2>列表</h2> <ul> <li>什么也没有看到。页面是空的、白色的。 (也称为<em>白页/死亡屏幕</em>)</li> <li>代码无法运行/输出了我的 PHP 代码的一部分</li> <li>警告:无法修改标头信息 - 标头已发送</li> <li>警告:mysql_fetch_array() 期望参数 1 为资源,给定的布尔值。<p><br /></p><p> 警告:mysql_fetch_array():提供的参数不是有效的 MySQL 结果资源</p></li> <li>警告:<em>[function]</em> 期望参数 1 为资源,给定布尔值</li> <li>警告:<em>[功能]</em>:无法打开流:<em>[原因]</em></li> <li>警告:open_basedir 限制生效</li> <li>警告:除以零</li> <li>警告:非法字符串偏移“XXX”</li> <li>警告:count():参数必须是数组或实现 Countable 的对象</li> <li>解析错误:语法错误,意外的“[”</li> <li>解析错误:语法错误,意外 T_XXX</li> <li>解析错误:语法错误,意外 T_ENCAPSED_AND_WHITESPACE</li> <li>解析错误:语法错误,意外 T_PAAMAYIM_NEKUDOTAYIM</li> <li>解析错误:语法错误、意外的“require_once”(T_REQUIRE_ONCE)、期望函数(T_FUNCTION)</li> <li>解析错误:语法错误,意外的 T_VARIABLE</li> <li>致命错误:允许的 XXX 字节内存大小已耗尽(尝试分配 XXX 字节)</li> <li>致命错误:超出最大执行时间 XX 秒</li> <li>致命错误:在非对象或 null 上调用成员函数...</li> <li>致命错误:调用未定义的函数 XXX</li> <li>致命错误:无法重新声明 XXX</li> <li>致命错误:无法在写入上下文中使用函数返回值</li> <li>致命错误:AAA::BBB() 的声明必须与 CCC::BBB() 的声明兼容'</li> <li>AAA::BBB() 的返回类型应与 CCC::BBB() 兼容,或者应使用 #[ReturnTypeWillChange] 属性</li> <li>致命错误:不在对象上下文中使用 $this</li> <li>致命错误:类 Closure 的对象无法转换为字符串</li> <li>致命错误:未定义的类常量</li> <li>致命错误:未捕获类型错误:参数 #n 必须是给定的 x、y 类型</li> <li>注意:数组到字符串转换 (< PHP 8.0) 或警告:数组到字符串转换 (>= PHP 8.0)</li> <li>注意:尝试获取非对象属性错误</li> <li>注意:未定义的变量或属性</li> <li>“注意:未定义索引”或“警告:未定义数组键”</li> <li>注意:未定义偏移 XXX [参考]</li> <li>注意:未初始化的字符串偏移量:XXX</li> <li>注意:使用未定义的常量 XXX - 假定为“XXX”/错误:未定义的常量 XXX</li> <li>MySQL:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 ... 行附近使用的正确语法</li> <li>严格标准:非静态方法<em>[<class>::<method>]</method></class></em>不应静态调用</li> <li>警告:函数期望参数 X 为布尔值/字符串/整数</li> <li>HTTP 错误 500 - 内部服务器错误</li> <li>已弃用:已弃用带有大括号的数组和字符串偏移访问语法</li> </ul> <p>另请参阅:</p> <ul> <li>参考 - 这个符号在 PHP 中意味着什么?</li> </ul><p><br /></p>
P粉478445671
P粉478445671

reply all(1)
P粉543344381

Warning: Unable to modify header information - header already sent

This occurs when your script attempts to send an HTTP header to the client but there has been output before, causing the header to have been sent to the client.

This is an E_WARNING and it does not stop the script.

A typical example is a template file like this:


    
    My Page

...

session_start() The function will attempt to send a header with the session cookie to the client. But PHP already sends the header when writing the element to the output stream. You have to move session_start() to the top.

You can solve this problem by looking at the line before the code that triggered the warning and checking where it is output. Move any header sending code before this code.

An often overlooked piece of output is the newline after PHP ends ?>. It is considered standard practice to omit ?> when it is the last thing in the file. Again, another common cause of this warning is when the starting is preceded by spaces, lines, or invisible characters, causing the web server to send headers and spaces/newlines, so when PHP starts parsing No headers will be submitted.

If you have multiple blocks in your file, there should not be any spaces between them. (Note: If you have auto-constructed code, you may have multiple blocks)

Also make sure there aren't any byte order marks in the code, such as when the script is encoded as UTF-8 with a BOM.

Related questions:

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!