What best practices should be followed when storing user input from HTML forms into PHP variables for further processing?

When storing user input from HTML forms into PHP variables for further processing, it is important to sanitize and validate the data to prevent security vulnerabilities such as SQL injection or cross-site scripting attacks. One common best practice is to use PHP functions like `htmlspecialchars()` or `mysqli_real_escape_string()` to sanitize user input before storing it in variables.

// Example of storing user input from an HTML form into PHP variables with sanitization
$name = htmlspecialchars($_POST['name']);
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$age = (int)$_POST['age'];