How does PHP determine whether a variable belongs in the $_POST or $_GET array when passed from the server?

PHP determines whether a variable belongs in the $_POST or $_GET array based on the method used to submit the data. If the data is sent using the POST method, it will be stored in the $_POST array. If the data is sent using the GET method, it will be stored in the $_GET array.

// Example of how PHP determines whether a variable belongs in the $_POST or $_GET array
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Variable belongs in $_POST array
    $variable = $_POST['variable_name'];
} else if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // Variable belongs in $_GET array
    $variable = $_GET['variable_name'];
}