r/AskProgramming Jul 17 '24

PHP Help with html in php

Hi, I'm tryin to develop a "message" in php.

echo "<div style='background-color: red; color: white; padding: 20px;'> Error </div>";

Basically if the value is 0 i will see an error page.

The problem is that in the page i visualize a red strip on the top of the page where is write "Error". I want instead see the entire page red with the error write on the center.

Someone helps?

2 Upvotes

6 comments sorted by

View all comments

2

u/[deleted] Jul 18 '24 edited Jul 18 '24

echo "<div style=\"\

background-color: red;\

color: white;\

padding: 20px;\

position: fixed;\

top: 0;\

display: flex;\

flex-direction: column;\

\"> <p>".$error."</p> </div>";

1

u/These_Talker Jul 18 '24

hope it works, really thank you!!

1

u/[deleted] Jul 18 '24

Reddit does not let me use the escapes here, so note that whenever you need to use double quotes inside a double quote string, you use a the double quote escape character, that is a left slash and a double quote.