Skip to main content

Text/Background color in Bash/PHP

The article this was taken from was for bash, and I was able to put the code into a PHP script and it worked when run in bash.

echo -e "\e[42m\e[30mVisa Required\e[0m\n";   # green  bkgrd,  black text
echo -e "\e[43m\e[30mVisa Required\e[0m\n";   # yellow bkgrd,  black text
echo -e "\e[44m\e[37mVisa Required\e[0m\n";   # blue    bkgrd,  white text
echo -e "\e[41m\e[37mVisa Required\e[0m\n";   # red      bkgrd,  white text


echo "30 & 40 indicate black\n";
echo "31 & 41 indicate red\n";
echo "32 & 42 indicate green\n";
echo "33 & 43 indicate yellow\n";
echo "34 & 44 indicate blue\n";
echo "35 & 45 indicate magenta\n";
echo "36 & 46 indicate ltBlue\n";
echo "37 & 47 indicate white\n";