PHP $_GET vs. $_POST

In PHP, $_GET and $_POST are superglobals used to send data from browser to web browser (e.g., in form handling).

Although both variables are used in collecting data, there are significant differences in how they’re used.

About $_GET

$_GET is an associative array of variables passed to the current script via the URL parameters (HTTP GET method).

HTTP GET method:

  • The requested data is available in browser history
  • The URL, including the request data, can be bookmarked
  • Limited to only sending up to 1024 characters
  • Never use the GET method if you have the password or other sensitive information sent to the server
  • Cannot be used to send binary data, like images or word documents, to the server

About $_POST

$_POST is an associative array of variables passed to the current script via the HTTP POST request method.

HTTP POST method:

  • No restriction on data size
  • Can be used to send ASCII as well as binary data, like images.
  • Data is sent in the HTTP header, so if you’re using Secure HTTP, your data is secured.

How to choose

Use $_GET (HTTP GET method) if your data is short text data that does not contain any sensitive information.

Use $_POST (HTTP POST method) to send lengthy data or binary data, like images. It is also used to send sensitive information.

Read more about the difference between HTTP GET and POST methods here.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved