在命令行上运行phpdbg时,从php_sapi_name()
返回的值是“phpdbg”而不是“cli”,这会破坏我的一些代码,这些代码会检查以确保代码是在CLI上运行而不是在Web服务中运行。
我宁愿不改变我的代码以适应调试器。有没有办法让phpdbg将SAPI报告为“cli”而不是“phpdbg”?
调用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