How can PHP distinguish between $_GET and $_POST variables?

PHP can distinguish between $_GET and $_POST variables by checking the request method used to submit the form data. If the request method is "GET", then the variables will be available in the $_GET superglobal array. If the request method is "POST", then the variables will be available in the $_POST superglobal array.

if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // Process $_GET variables
    $var = $_GET['var_name'];
} elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Process $_POST variables
    $var = $_POST['var_name'];
}