What considerations should be taken into account when allowing users to input text with line breaks in PHP?

When allowing users to input text with line breaks in PHP, it is important to sanitize the input to prevent any potential security vulnerabilities such as cross-site scripting attacks. One way to do this is by using the `nl2br()` function in PHP, which converts newline characters to HTML `<br>` tags. This ensures that line breaks are displayed properly on the webpage without compromising security.

$user_input = $_POST[&#039;user_input&#039;];
$sanitized_input = nl2br(htmlspecialchars($user_input));
echo $sanitized_input;