PHP 运行时错误 [英] PHP runtime error

查看:71
本文介绍了PHP 运行时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写 PHP 有一段时间了.

I'm programming PHP for some time.

我使用带有 PHP 5.4SQlite 3Apache 2.4Windows XP SP3 作为开发环境.远程主机服务器(不是我的)是带有 PHP 5.3Apache 2.2IIS 7.0Windows Server 2008SQL Server 2008.

I use an Windows XP SP3 with PHP 5.4, SQlite 3, Apache 2.4 as a development environment. The remote host server (not mine) is a Windows Server 2008 with PHP 5.3, Apache 2.2, IIS 7.0 and SQL Server 2008.

我的编辑器是简单而出色的 EditPlus.

My editor is the simple and wonderful EditPlus.

关于 Javascript 很好,因为 Firefox 加上很棒的附加组件 FireBug,它允许完整的 HTML + CSS + Javascript 调试.

Concerning Javascript it's nice because of Firefox plus the great add-on FireBug, which allows for complete HTML + CSS + Javascript debugging.

我的问题是我的开发环境(我的个人机器)中的 PHP 错误管理.

My problem is PHP error management in my development environment (my personal machine).

PHP 语法错误通常与行号等一起显示正常,可以轻松修复.还有用于检查语法的在线工具(例如 pilliap)和其他用于测试的在线工具PHP 片段的执行(例如 writecodeonline.com )

The PHP syntax errors typically appear ok with line number and so on, allowing easy fix. Also there are online tools for check syntax (e.g pilliap) and other online tools to test the execution of PHP snippets (E.g writecodeonline.com )

然而,我的诅咒是运行时错误(例如,未初始化的变量$_SESSION).有时它显示正确,但有时错误消息(包括正确的行号!)嵌入在源代码中,在虚假的 HTML 标签中.简单的测试显示没有问题.但我的真实代码通常可以.

However, my curse is runtime errors (eg, uninitialized variable $ _SESSION). Sometimes it shows correctly, but other times the error message (including the right line number!) are embedded within the source code, inside spurious HTML tags. Simple tests shows no problem. but my real code generally does.

这不是阻止我前进的情况,而是令人不快.

It is not a situation that does stop me from moving forward, but it is unpleasant.

我在互联网上没有找到任何关于这种奇怪行为的提示,我很好奇是否有人可以提供线索.

I did not find any hint on the Internet about this strange behavior and I'm very curious if somebody can give a clue about it.

我的问题:PHP 运行时错误怎么可能有时出现在浏览器中(如开发环境中所希望的那样),有时它出现在 Javascript + HTML 源代码中以及虚假的 HTML 标签中?

PS:不是 PHP 日志文件或 PHP.Ini 文件中的显示错误设置的问题.

PS2:无论是否安装 XDebug,都会出现相同的情况.

推荐答案

使用 php error_log() 函数 以您想要的方式显示有关您的错误的信息.

Use the php error_log() function to show information about your errors the way you want.

除此之外,请查看您的 php.ini 配置文件.有许多变量(html_errorserror_logdisplay_errorserror_reporting ...)来设置错误的输出如您所愿,这样它们就不会弄乱 html 输出.

Apart from that, have a look at your php.ini configuration file. There are many variables (html_errors, error_log, display_errors, error_reporting ...) to setup the output of errors as you want so they not mess up the html output.

这篇关于PHP 运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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