当在命令行上运行phpdbg时,从php_sapi_name()返回的值是"phpdbg“而不是" CLI ",这会扰乱我的一些代码,以确保代码是在命令行界面上运行的,而不是在web服务中运行的。
我不想为了适应调试器而更改代码。有没有办法让phpdbg将SAPI报告为"cli“而不是"phpdbg"?
发布于 2018-03-05 10:06:45
在调用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 ithttps://stackoverflow.com/questions/49102518
复制相似问题