<i id='N6U6L'><tr id='N6U6L'><dt id='N6U6L'><q id='N6U6L'><span id='N6U6L'><b id='N6U6L'><form id='N6U6L'><ins id='N6U6L'></ins><ul id='N6U6L'></ul><sub id='N6U6L'></sub></form><legend id='N6U6L'></legend><bdo id='N6U6L'><pre id='N6U6L'><center id='N6U6L'></center></pre></bdo></b><th id='N6U6L'></th></span></q></dt></tr></i><div id='N6U6L'><tfoot id='N6U6L'></tfoot><dl id='N6U6L'><fieldset id='N6U6L'></fieldset></dl></div>

      <bdo id='N6U6L'></bdo><ul id='N6U6L'></ul>

      <tfoot id='N6U6L'></tfoot>

      <small id='N6U6L'></small><noframes id='N6U6L'>

    1. <legend id='N6U6L'><style id='N6U6L'><dir id='N6U6L'><q id='N6U6L'></q></dir></style></legend>
      1. 对 PHP 的 Windows 命令行输出进行着色

        时间:2023-09-25
          <bdo id='GBv7O'></bdo><ul id='GBv7O'></ul>

          <small id='GBv7O'></small><noframes id='GBv7O'>

            <legend id='GBv7O'><style id='GBv7O'><dir id='GBv7O'><q id='GBv7O'></q></dir></style></legend>

              <tbody id='GBv7O'></tbody>
            • <tfoot id='GBv7O'></tfoot>

                  <i id='GBv7O'><tr id='GBv7O'><dt id='GBv7O'><q id='GBv7O'><span id='GBv7O'><b id='GBv7O'><form id='GBv7O'><ins id='GBv7O'></ins><ul id='GBv7O'></ul><sub id='GBv7O'></sub></form><legend id='GBv7O'></legend><bdo id='GBv7O'><pre id='GBv7O'><center id='GBv7O'></center></pre></bdo></b><th id='GBv7O'></th></span></q></dt></tr></i><div id='GBv7O'><tfoot id='GBv7O'></tfoot><dl id='GBv7O'><fieldset id='GBv7O'></fieldset></dl></div>
                  本文介绍了对 PHP 的 Windows 命令行输出进行着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  要在 bash 中输出彩色文本,您可以使用 ANSI 转义序列.

                  To output colored text in bash, you use ANSI escape sequences.

                  如何在 Windows 命令行上输出彩色文本,特别是从 PHP 输出?

                  How do you output colored text on a Windows command line, specifically from PHP?

                  推荐答案

                  从以下位置下载 dynwrap.dll:http://www.script-coding.com/dynwrap95.zip

                  Download dynwrap.dll from : http://www.script-coding.com/dynwrap95.zip

                  然后将其解压到%systemroot%system32目录,然后在命令行中运行以下命令:

                  Then extract it to %systemroot%system32 directory and then run following command in command line:

                  regsvr32.exe "%systemroot%system32dynwrap.dll"

                  您将收到一条成功消息,表示 dynwrap.dll 已注册.

                  You'll get a success message which means dynwrap.dll is registered.

                  那么你可以这样使用它:

                  Then you can use it this way :

                  $com = new COM('DynamicWrapper');
                  
                  // register needed features
                  $com->Register('kernel32.dll', 'GetStdHandle', 'i=h', 'f=s', 'r=l');
                  $com->Register('kernel32.dll', 'SetConsoleTextAttribute', 'i=hl', 'f=s', 'r=t');
                  
                  // get console handle
                  $ch = $com->GetStdHandle(-11);
                  

                  一些例子:

                  $com->SetConsoleTextAttribute($ch, 4);
                  echo 'This is a red text!';
                  $com->SetConsoleTextAttribute($ch, 7);
                  echo 'Back to normal color!';
                  

                  颜色代码:
                  7 => 默认
                  0 => 黑色
                  1 => 蓝色
                  2 => 绿色
                  3 => 水色
                  4 => 红色
                  5 => 紫色
                  6 => 黄色
                  7 => 浅灰色
                  8 => 灰色
                  9 => 浅蓝色
                  10 => 浅绿色
                  11 => 浅水色
                  12 => 浅红色
                  13 => 浅紫色
                  14 => 浅黄色
                  15 => 白色

                  colors codes:
                  7 => default
                  0 => black
                  1 => blue
                  2 => green
                  3 => aqua
                  4 => red
                  5 => purple
                  6 => yellow
                  7 => light gray
                  8 => gray
                  9 => light blue
                  10 => light green
                  11 => light aqua
                  12 => light red
                  13 => light purple
                  14 => light yellow
                  15 => white

                  这篇关于对 PHP 的 Windows 命令行输出进行着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PHP 在命令提示符中未被识别为内部或外部命令 下一篇:Windows CMD.exe“系统找不到指定的路径."

                  相关文章

                  最新文章

                    <legend id='2rpnC'><style id='2rpnC'><dir id='2rpnC'><q id='2rpnC'></q></dir></style></legend>
                    • <bdo id='2rpnC'></bdo><ul id='2rpnC'></ul>
                      <tfoot id='2rpnC'></tfoot>

                      <small id='2rpnC'></small><noframes id='2rpnC'>

                    1. <i id='2rpnC'><tr id='2rpnC'><dt id='2rpnC'><q id='2rpnC'><span id='2rpnC'><b id='2rpnC'><form id='2rpnC'><ins id='2rpnC'></ins><ul id='2rpnC'></ul><sub id='2rpnC'></sub></form><legend id='2rpnC'></legend><bdo id='2rpnC'><pre id='2rpnC'><center id='2rpnC'></center></pre></bdo></b><th id='2rpnC'></th></span></q></dt></tr></i><div id='2rpnC'><tfoot id='2rpnC'></tfoot><dl id='2rpnC'><fieldset id='2rpnC'></fieldset></dl></div>