Last active
November 16, 2015 08:18
-
-
Save Saberko/adba0690e2c9f9e0f46d to your computer and use it in GitHub Desktop.
php控制台输出带颜色信息
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function out($text, $status) { | |
$str = ''; | |
switch($status) { | |
case 'SUCCESS': | |
$str = "[42m"; | |
break; | |
case 'FAIL': | |
$str = "[41m"; | |
break; | |
case 'WARNING': | |
$str = "[43m"; | |
break; | |
case "NOTE": | |
$str = "[44m"; | |
break; | |
default: | |
throw new Exception('Invalid status: ' . $status); | |
} | |
echo chr(27) . $str . $text . chr(27) . "[0m" . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment