10. Parameters, argument and Superglobals

Parameters & argument: The parameters are what are used inside the function and the arguments are the values passed when the function is called.
So here, x and y would be formal parameters:
int foo(int x, int y) { … }
Whereas here, in the function call, 5 and z are the actual arguments:
foo(5, z);

Superglobals: These arrays are known as superglobals because they’re accessible from anywhere in your script — including inside functions — and you don’t need to declare them as global using the global keyword.

Here’s a full list of the superglobals available in PHP, as of version 5.3:

$GLOBALS         Contains a list of all global variables in the script

$_GET                 Holds a list of all form fields sent by the browser using the get request

$_POST              Holds a list of all form fields sent by the browser using the post request

$_COOKIE          Holds a list of all cookies sent by the browser

$_REQUEST       Contains all the keys and values in the $_GET, $_POST and $_COOKIE arrays combined

$_FILES              Holds a list of any files uploaded by the browser

$_SESSION        Allows you to store and retrieve persistent session variables for the current browser

$_SERVER         Holds server environment info such as the filename of the running script, and the IP address of the browser.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s