有phpdbg报告SAPI为“cli”而不是“phpdbg”

问题描述 投票:0回答:1

在命令行上运行phpdbg时,从php_sapi_name()返回的值是“phpdbg”而不是“cli”,这会破坏我的一些代码,这些代码会检查以确保代码是在CLI上运行而不是在Web服务中运行。

我宁愿不改变我的代码以适应调试器。有没有办法让phpdbg将SAPI报告为“cli”而不是“phpdbg”?

php command-line-interface phpdbg
1个回答
0
投票

调用phpdbg时,您可以指定-S开关以指定要报告为SAPI的任何名称。例如phpdbg -Scli将其恢复为“cli”。

phpdbg的官方在线文档是在https://phpdbg.room11.org/。然而,它似乎非常过时,并没有提到-S选项。要查看当前的选项列表,请运行phpdbg并使用help options命令。

$ phpdbg
prompt> help options

Below are the command line options supported by phpdbg

Command Line Options and Flags
  Option  Example Argument    Description
  -c      -c/my/php.ini       Set php.ini file to load
  -d      -dmemory_limit=4G   Set a php.ini directive
  -n                          Disable default php.ini
  -q                          Suppress welcome banner
  -v                          Enable oplog output
  -b                          Disable colour
  -i      -imy.init           Set .phpdbginit file
  -I                          Ignore default .phpdbginit
  -O      -Omy.oplog          Sets oplog output file
  -r                          Run execution context
  -rr                         Run execution context and quit after execution (not respecting
breakpoints)
  -e                          Generate extended information for debugger/profiler
  -E                          Enable step through eval, careful!
  -s      -s=, -s=foo         Read code to execute from stdin with an optional delimiter
  -S      -Scli               Override SAPI name, careful!
  -l      -l4000              Setup remote console ports
  -a      -a192.168.0.3       Setup remote console bind address
  -x                          Enable xml output (instead of normal text output)
  -p      -p, -p=func, -p*    Output opcodes and quit
  -h                          Print the help overview
  -V                          Print version number
  --      -- arg1 arg2        Use to delimit phpdbg arguments and php $argv; append any $argv argument after it
© www.soinside.com 2019 - 2024. All rights reserved.