Last active
November 14, 2019 09:05
-
-
Save sokil/db2c4e103be7d7aaeb0d to your computer and use it in GitHub Desktop.
Console color
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 | |
| // new lines | |
| // echo "\033[{$line};{$column}H"; | |
| // \r - goto start of line | |
| $foregroundColors = array( | |
| 'white' => '1;37', | |
| 'black' => '0;30', | |
| 'dark_gray' => '1;30', | |
| 'light_gray' => '0;37', | |
| 'blue' => '0;34', | |
| 'light_blue' => '1;34', | |
| 'green' => '0;32', | |
| 'light_green' => '1;32', | |
| 'cyan' => '0;36', | |
| 'light_cyan' => '1;36', | |
| 'red' => '0;31', | |
| 'light_red' => '1;31', | |
| 'purple' => '0;35', | |
| 'light_purple' => '1;35', | |
| 'brown' => '0;33', | |
| 'yellow' => '1;33', | |
| ); | |
| $backgroundColors = array( | |
| 'black' => '40', | |
| 'red' => '41', | |
| 'green' => '42', | |
| 'yellow' => '43', | |
| 'blue' => '44', | |
| 'magenta' => '45', | |
| 'cyan' => '46', | |
| 'light_gray' => '47', | |
| ); | |
| echo "\033[" . $foregroundColors['black'] . 'm' . // foreground | |
| "\033[" . $backgroundColors['green'] . 'm' . // background | |
| 'Hello world' . // message | |
| "\033[0m"; // stop bytes | |
| /* | |
| Red: "\033[0;31mHELLOWORLD\033[0m" | |
| Green: "\033[0;32mHELLOWORLD\033[0m" | |
| */ | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://habrahabr.ru/post/45041/