What is the common issue with displaying data in a form when values contain spaces in PHP?

When displaying data in a form in PHP, a common issue arises when the values contain spaces. This is because HTML treats spaces as delimiters, causing the form fields to break up. To solve this issue, we can use the `htmlspecialchars()` function to encode the values before displaying them in the form.

<?php
$data = "John Doe";
$data_encoded = htmlspecialchars($data);
echo "<input type='text' name='name' value='$data_encoded'>";
?>