Problem with space in txt file when used in PHP

Here is the program code:

echo "<form action=redaktor.php method=GET>";
echo "<input type=text value=$read name=cena1>";
echo "</form>";

I enter a value with a space into the $read variable (optional) and it violates the html code of the page… What should I do?

Answer 1, authority 100%

Use quotes in tag parameters, of course. Is always.

echo "<form action='redaktor.php' method='GET'>";
echo "<input type='text' value='$read' name='cena1' />";
echo "</form>";

Of course, if similar quotes are formed in a variable, then the tag will be broken. But, of course, this is easy to avoid.

Answer 2, authority 50%

Don’t forget about escaping, example :

echo "<form action=\"redaktor.php\" method=\"GET\">";

Or use other quotes :

echo '<form action="redaktor.php" method="GET">';

Usually double quotes are used for attribute values.

Answer 3, authority 25%

Don’t forget to use quotes