當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Console::ansiFormatCode方法代碼示例

本文整理匯總了PHP中yii\helpers\Console::ansiFormatCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Console::ansiFormatCode方法的具體用法?PHP Console::ansiFormatCode怎麽用?PHP Console::ansiFormatCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\helpers\Console的用法示例。


在下文中一共展示了Console::ansiFormatCode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ansiFormats

 public function ansiFormats()
 {
     return [['test', 'test'], [Console::ansiFormat('test', [Console::FG_RED]), '<span style="color: red;">test</span>'], ['abc' . Console::ansiFormat('def', [Console::FG_RED]) . 'ghj', 'abc<span style="color: red;">def</span>ghj'], ['abc' . Console::ansiFormat('def', [Console::FG_RED, Console::BG_GREEN]) . 'ghj', 'abc<span style="color: red;background-color: lime;">def</span>ghj'], ['abc' . Console::ansiFormat('def', [Console::FG_GREEN, Console::FG_RED, Console::BG_GREEN]) . 'ghj', 'abc<span style="color: red;background-color: lime;">def</span>ghj'], ['abc' . Console::ansiFormat('def', [Console::BOLD, Console::BG_GREEN]) . 'ghj', 'abc<span style="font-weight: bold;background-color: lime;">def</span>ghj'], [Console::ansiFormat('test', [Console::UNDERLINE, Console::OVERLINED, Console::CROSSED_OUT, Console::FG_GREEN]), '<span style="text-decoration: underline overline line-through;color: lime;">test</span>'], [Console::ansiFormatCode([Console::RESET]) . Console::ansiFormatCode([Console::RESET]), ''], [Console::ansiFormatCode([Console::RESET]) . Console::ansiFormatCode([Console::RESET]) . 'test', 'test'], [Console::ansiFormatCode([Console::RESET]) . 'test' . Console::ansiFormatCode([Console::RESET]), 'test'], [Console::ansiFormatCode([Console::BOLD]) . 'abc' . Console::ansiFormatCode([Console::RESET, Console::FG_GREEN]) . 'ghj' . Console::ansiFormatCode([Console::RESET]), '<span style="font-weight: bold;">abc</span><span style="color: lime;">ghj</span>'], [Console::ansiFormatCode([Console::FG_GREEN]) . ' a ' . Console::ansiFormatCode([Console::BOLD]) . 'abc' . Console::ansiFormatCode([Console::RESET]) . 'ghj', '<span style="color: lime;"> a <span style="font-weight: bold;">abc</span></span>ghj'], [Console::ansiFormat('test', [Console::FG_GREEN, Console::BG_BLUE, Console::NEGATIVE]), '<span style="background-color: lime;color: blue;">test</span>'], [Console::ansiFormat('test', [Console::NEGATIVE]), 'test'], [Console::ansiFormat('test', [Console::CONCEALED]), '<span style="visibility: hidden;">test</span>']];
 }
開發者ID:howq,項目名稱:yii2,代碼行數:4,代碼來源:ConsoleTest.php

示例2: log

 public function log($type, $color, $string, $base = [Console::NORMAL], $colors = NULL)
 {
     if (!sizeof($colors)) {
         $colors = [[Console::FG_YELLOW], [Console::FG_BLUE]];
     }
     echo Console::ansiFormat('[', [Console::NORMAL]);
     echo Console::ansiFormat($type, $color);
     echo Console::ansiFormat('] ', [Console::NORMAL]);
     $string = ']]' . $string;
     $string = str_replace(']]', Console::ansiFormatCode([Console::NORMAL]) . Console::ansiFormatCode($base), $string);
     for ($i = 1; $i < 10; $i++) {
         if (isset($colors[$i])) {
             $clr = $colors[$i];
         } else {
             $clr = $colors[0];
         }
         $string = str_replace("[[{$i}", Console::ansiFormatCode($clr), $string);
     }
     $string = str_replace('[[', Console::ansiFormatCode($colors[0]), $string);
     $string .= Console::ansiFormatCode([Console::NORMAL]) . "\n";
     echo $string;
 }
開發者ID:simplator,項目名稱:yii2-quickrbac,代碼行數:22,代碼來源:QuickRBAC.php


注:本文中的yii\helpers\Console::ansiFormatCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。