You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在命令行调用PHP时显示错误且不写入error_log文件?

命令行PHP开启终端错误显示并禁用错误日志写入

有两种可行的方法实现需求:

  • 定向错误日志到空设备(推荐,不影响其他日志配置)
    在命令行添加error_log配置项,将日志输出指向系统空设备,这样既不会生成本地error_log文件,又能在终端显示错误:

    • Linux/macOS环境:
      php -d display_errors=on -d error_log=/dev/null filename.php
      
    • Windows环境:
      php -d display_errors=on -d error_log=NUL filename.php
      
  • 直接关闭错误日志功能
    通过log_errors配置项关闭所有错误日志记录,同样能达到目的,但会禁用所有错误日志输出(包括系统级日志):

    php -d display_errors=on -d log_errors=off filename.php
    

内容的提问来源于stack exchange,提问作者Tristan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 09:06:17