Skip to content

Instantly share code, notes, and snippets.

@dekokun
Created February 3, 2012 10:11
Show Gist options
  • Save dekokun/1729491 to your computer and use it in GitHub Desktop.
Save dekokun/1729491 to your computer and use it in GitHub Desktop.
PHPで標準出力の色やスタイルを変える
<?php
$color = array(
'black' => 30,
'red' => 31,
'green' => 32,
'brown' => 33,
'blue' => 34,
'purple' => 35,
'cyan' => 36,
'grey' => 37,
'yellow' => 33
);
$style = array(
'normal' => 0,
'bold' => 1,
'light' => 1,
'underscore' => 4,
'underline' => 4,
'blink' => 5,
'inverse' => 6,
'hidden' => 8,
'concealed' => 8
);
$background = array(
'black' => 40,
'red' => 41,
'green' => 42,
'brown' => 43,
'yellow' => 43,
'blue' => 44,
'purple' => 45,
'cyan' => 46,
'grey' => 47
);
print "\033[" . $color['red'] . "m";
print "\033[" . $style['underscore'] . "m";
print "\033[" . $background['blue'] . "m";
print 'test';
print "\033[" . $style['normal'] . "m";
// thank you pear/Console_Color !!!
@dekokun
Copy link
Author

dekokun commented Feb 3, 2012

Thank you for pear/Console_Color !!!!!!

http://pear.php.net/package/Console_Color/redirected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment