Is there a preferred method for accessing post variables in PHP?

When accessing post variables in PHP, there are multiple methods available such as using the $_POST superglobal or the filter_input() function. A preferred method is to use the filter_input() function with the INPUT_POST filter type as it provides a secure and sanitized way to access post variables.

// Using filter_input() function to access post variables
$variable_name = filter_input(INPUT_POST, 'variable_name', FILTER_SANITIZE_STRING);