本文整理汇总了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>']];
}
示例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;
}