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!';
PHP doesn't have built-in functionality for changing the font size or color. We can use HTML and CSS with PHP to change the font size and color.
The echo is used to display the output of parameters that are passed to it. It displays the outputs of one or more strings separated by commas. The print accepts one argument at a time & cannot be used as a variable function in PHP.
echo and print are more or less the same. They are both used to output data to the screen. The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions.
To set the font color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property color. HTML5 do not support the <font> tag, so the CSS style is used to add font color.
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 ;))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With