-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColor.php
More file actions
36 lines (34 loc) · 1 KB
/
Color.php
File metadata and controls
36 lines (34 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* @title: Color.php
* @description: PHP终端输出彩色
* @author: songxinkai@gmail.com
* @date: 2016-01-14
* @copyright Copyright (c) 2015-2016 www.songxinkai.com
*/
class Color {
const BLACK = '30';
const RED = '31';
const GREEN = '32';
const YELLOW = '33';
const BLUE = '34';
const MAGENTA = '35';
const CYAN = '36';
const LIGHT_GRAY = '37';
const DARK_GRAY = '90';
const LIGHT_RED = '91';
const LIGHT_GREEN = '92';
const LIGHT_YELLOW = '93';
const LIGHT_BLUE = '94';
const LIGHT_MAGENTA = '95';
const LIGHT_CYAN = '96';
const WHITE = '97';
const BOLD = '1';
const DIM = '2';
const UNDERLINED = '4';
const REVERSE = '7';
const HIDDEN = '8';
public static function format($string, $color, $style = array()) {
return "\033[".implode(';', array_merge($style, array($color))).'m'.$string."\033[0m";
}
}