How can the strip_tags() function be utilized to prevent HTML code from being displayed in a textarea in PHP?

When displaying user input in a textarea in PHP, it is important to prevent any HTML code from being executed to avoid security vulnerabilities like cross-site scripting (XSS) attacks. One way to achieve this is by using the strip_tags() function to remove any HTML tags from the input before displaying it in the textarea. This function will strip all HTML tags from the input, ensuring that only plain text is displayed.

<?php
// Get user input from a form
$user_input = $_POST['user_input'];

// Remove any HTML tags from the user input using strip_tags()
$clean_input = strip_tags($user_input);

// Display the cleaned input in a textarea
echo '<textarea>' . $clean_input . '</textarea>';
?>