PHP Echo text Color


Question

How do I change the color of an echo message and center the message in the PHP I've written. The line I have is:

echo 'Request has been sent. Please wait for my reply!';

1
20
11/7/2009 1:54:26 AM

Accepted Answer

How about writing out some HTML tags and some CSS if you're outputting this to the browser?

echo '<span style="color:#AFA;text-align:center;">Request has been sent. Please wait for my reply!</span>';

Won't work from console though, only through browser.

13
12/13/2013 5:08:29 AM

How about writing out some escape sequences?

echo "\033[01;31m Request has been sent. Please wait for my reply! \033[0m";

Won't work through browser though, only from console ;))


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon