如何为PHP CLI启用颜色?
2022-08-30 13:46:43
对于懒惰者
function colorLog($str, $type = 'i'){
switch ($type) {
case 'e': //error
echo "\033[31m$str \033[0m\n";
break;
case 's': //success
echo "\033[32m$str \033[0m\n";
break;
case 'w': //warning
echo "\033[33m$str \033[0m\n";
break;
case 'i': //info
echo "\033[36m$str \033[0m\n";
break;
default:
# code...
break;
}
}