PHP 错误日志和换行符 [英] PHP error log and newline chars

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

问题描述

允许或防止调试输出中的换行符被转义的 PHP 配置设置是什么?

What's the PHP config setting which allows or prevents newlines in debug output from being escaped?

在两个不同的安装(运行 MAMP/OSX 的开发笔记本电脑和运行 debian 的开发服务器)上,我在调试时在错误日志中看到不同的结果.

On two different installs (a dev laptop running MAMP/OSX, and a dev server running debian) I see different results in the error logs when debugging.

error_log(print_r(array(1,2,4),1));

在 Debian 上,这在/var/log/apache2/error.log 中显示为

On Debian this appears in /var/log/apache2/error.log as

[Thu Jul 30 11:32:34 2009] [error] [client 118.93.246.104] Array\n(\n    [0] => 1\n    [1] => 2\n    [2] => 4\n)\n, referer: http://dev.example.org/

在 OSX 上,这在/Applications/MAMP/logs/php_error_log 中显示为

On OSX this appears in /Applications/MAMP/logs/php_error_log as

[30-Jul-2009 11:34:00] Array
(
    [0] => 1
    [1] => 2
    [2] => 4
)

我更喜欢 MAMP 调试方式(除了将日志文件重定位到/Applications 目录).

I prefer the MAMP way for debugging (apart from relocating logfiles to the /Applications directory).

谢谢!

推荐答案

Chris,您应该能够将 Debian 上的 php.ini 中的 error_log 指令更改为指向一个文件.如果未定义,它将通过不支持多行的系统日志.

Chris, you should be able to change the error_log directive in your php.ini on Debian to point to a file. If this is undefined, it will go through syslog which doesn't support multiple lines.

详情:

error_log 函数

error_log 指令

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

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