Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive, so $Abc is different from $abc.
A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.
Comment is a part of your PHP code that will not be translated by the PHP engine. You can use it to write documentation of your PHP script describing what the code should do. A comment can span only for one line or span multiple line.
PHP support three kinds of comment tags :
//
This is a one line comment
#
This is a Unix shell-style comment. It's also a one line comment
/* ..... */
Use this multi line comment if you need to.
* For all PHP code in this website I will use the comment by gray text and result of the code show you with italic character.
PHP supports eight primitive types.
boolean : expresses truth value, TRUE or FALSE. Any non zero values and non empty string are also counted as TRUE.
integer : round numbers (-5, 0, 10, 2364, ...)
float : floating-point number or 'double' (0.9238, 26.0, ...)
string : "Hello World", 'PHP MySQL', etc.
array
object
resource ( one example is the return value of mysql_connect() function)
Strings are probably what you will use most in your PHP script. To declare a string in PHP you can use double quotes ( " ) or single quotes ( ' ). There are some differences you need to know about using these two.
In PHP an array can have numeric key, associative key or both. The value of an array can be of any type. To create an array use the array() language construct.
Superglobals are variables that available anywhere in the program code. They are :
$_SERVER
Variables set by the web server or otherwise directly related to the execution environment of the current script. One useful variable is $_SERVER['REMOTE_ADDR'] which you can use to know you website visitor's IP address
$_GET
Variables provided to the script via HTTP GET. You can supply GET variables into a PHP script by appending the script's URL like this : http://www.phpeasily.com/test.php?a=100
or set the a form method as method="get"
$_POST
Variables provided to the script via HTTP POST. These comes from a form which set method="post"
$_COOKIE
Variables provided to the script via HTTP cookies.
$_FILES
Variables provided to the script via HTTP post file uploads.
$_ENV
Variables provided to the script via the environment.
$_REQUEST
Variables provided to the script via the GET, POST, and COOKIE input mechanisms, and which therefore cannot be trusted. It's use the appropriate $_POST or $_GET from your script instead of using $_REQUEST so you will always know that a variable comes from POST or GET.
$GLOBALS
Contains a reference to every variable which is currently available within the global scope of the script.