$_GET

The $_GET superglobal contains variables passed to a PHP script through the HTTP GET method. These values come from the URL query string or from HTML forms that use method="get".

Each query parameter becomes a key in the $_GET array, using the parameter name as the key and the provided value as the value. Because GET parameters are part of the URL, they are visible, bookmarkable, and easily shared.

GET requests are typically used for reading data, such as filtering lists, searching content, pagination, or selecting views. They should not be used for sensitive data, since the values appear in the URL.

As with all user input, data from $_GET should always be checked for existence and sanitized before being used or output.

Key points:

  • Data comes from the URL query string
  • Values are visible in the browser address bar
  • Commonly used for searches, filters, and navigation
  • Always check and sanitize input