Why is it recommended to use POST requests instead of GET requests when modifying data in PHP?

It is recommended to use POST requests instead of GET requests when modifying data in PHP because POST requests are more secure and can handle larger amounts of data. GET requests append data to the URL which can be visible to users and stored in browser history. POST requests send data in the body of the request, keeping it hidden from users.

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  // Code to handle modifying data
}