tags:

views:

755

answers:

5

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!';

+3  A: 

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

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.

thephpdeveloper
A: 

If it echoing out to a browser, you should use CSS. This would require also having the comment wrapped in an HTML tag. Something like:

echo '<p style="color: red; text-align: center">
      Request has been sent. Please wait for my reply!
      </p>';
Anthony
A: 

Use the below code, it would be faster for you if you go through a basic HTML/CSS Tutorial.

echo '<div style="text-align:center; color:red">Request has been sent. Please wait for my reply!</div>';
Thiyagaraj
+3  A: 

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 ;))

o_O Tync
A: 

If you want send ANSI color to console, get this tiny package,

http://pear.php.net/package/Console%5FColor

ZZ Coder