PHP: ANSI color sequences for the CLI

I was doing some CLI work and needed the ANSI color sequence for PHP. So I don't have too look it up again here it is.

$green = "\033[38;5;2m";
$reset = "\033[0m";

print $green . "Green" . $reset . " not green";

Change the 2 in $green to whatever color is appropriate.

Leave A Reply
All content licensed under the Creative Commons License