In "execution blocks" I see a lot $_SESSION
for form validation and the like, but I do not quite understand what exactly it means.
In "execution blocks" I see a lot $_SESSION
for form validation and the like, but I do not quite understand what exactly it means.
These are pre-defined variables as per documentation . They are populated by the PHP runtime virtual machine according to the execution context, so they are like internal objects exposed to your access code.
It's a simple and useful template, but if it were today I doubt the language would use something like this, since the language is mutating to be more enterprise and less than script >, where the context fit.
Specifically, $_SESSION
stores a unique code that indicates which session is active, so it is possible for a script to identify that its call is still part of a user session and can thus give continuity to what it did in previous executions. The web is stateless , so it does not save the situation between one call and another, your code has to deal with it, and a session identifier is the way to know what the session is, usually it is passed between the browser and the HTTP server by cookies .
Other cookies can be accessed by the $_COOKIE
variable. Data coming from the browser can be picked up by $_GET
, $_POST
, and $_FILES
to get files being uploaded, or $_SERVER
for specific execution environment and call data, or $_ENV
for the general environment
$_REQUEST
is indifferent between get and post , and can be used when no matter what form the request came from.
Among some others, even with slightly different standards, you still have $GLOBALS
to store accessible values for every script run (which is usually very fast).
Whenever you find variables that start with $ _ means they are super global variables, that is, they are special variables that can be used anywhere in your project, and each has a specific function.
For example $ _SESSION ['example'] creates a session, $ _GET takes the values of the URL variables ... etc ...