| |
|
|
| You
are currently reading |
 |
|
|
|
|
| The
article requested: |
 |
|
|
|
PHP variables Continued We've covered some part of PHP variables and it's time to move on for more about them. PHP also has predefined variables that are available for programming purposes such as communicating between the client and server, forms interactions, etc. Let's get to it.
Predefined variables PHP comes with built-in predefined variables informing us about configurations, user unput and a lot more. The values for each of the predefined variables are not always the same because their values depend on your server configuration and other factors. These variables are superglobals, therefore, they can be used in every scope of your script. I'll explain about variable scopes in the future, for now you just need to have a good understanding about the variables in PHP.
Let's have a look now at each of the predefined variables:
- $GLOBALS
This holds every variable that is within the global scope of a php script. - $_SERVER
This holds every value generated by the webserver or the script being executed. - $_GET
This holds every variable defined by you in a form, $_GET normally holds user input through the URL. e.g. (index.php?name=andres&lastname=robalino) - $_POST
Holds every variable through forms too, the difference between $_GET and $_POST is that $_POST holds user input from the post method which is more secure when dealing with users and passwords. - $_COOKIE
You probably heard of the word cookies, this holds every cookie that the server has sent to your computer. - $_FILES
Holds values from the HTTP post file uploads. - $_ENV
Values that provide you with the Environment of the script - $_REQUEST
It holds variables of user input and cookies as well, this isn't secure, it's better to use the $_POST, $_GET, $_COOKIE for security reasons. - $_SESSION
Holds every variable inside a session, when you view a website and you interact with the website, a session is currently active.
|
[1][2][3][4][Determining variables type]
|
|