0

コマンド ラインでphpdbgを実行すると、返される値php_sapi_name()は「cli」ではなく「phpdbg」になります。これにより、コードが Web サービスではなく CLI で実行されていることを確認するコードの一部が混乱します。

デバッガーに合わせてコードを変更したくありません。phpdbg に SAPI を「phpdbg」ではなく「cli」として報告させる方法はありますか?

4

1 に答える 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
于 2018-03-05T02:06:44.717 に答える