Superglobals are the functions that are accessible in any function, class or file. There is no specified scope or any special way to access the superglobals. PHP facilitates with two superglobals to create and to collect form data. These are:
It is an array of variables which is passed to the current script using the URL parameters.
It is an array of variables which is passed to the current script using the HTTP POST method.
Difference between GET and POST:
GET and POST are used to create an array to hold the name of the form controls as a key within the array and to hold the user fed data as the value of the respected key. The difference between the two are listed below:
|Information sent is visible to everyone.||Information sent is invisible to others.|
|All the names and values are displayed in the URL.||All the names and values are embedded inside the HTTP request body.|
|It has a limit of about 2000 characters on the amount of information to send.||There is no limit on the amount of information to send, in case of POST.|
|It is possible to bookmark the page.||It is not possible to bookmark the page.|
|GET should be used for sending non-sensitive data only.||POST can be used for sending sensitive data also.|
|No advanced functionality available.||Advanced functionality like multi-part binary input (while uploading files to server) is also available.|
Example 1: To receive data from get request in PHP.
Example 2: To receive data from post request in PHP.