Comments
Comments are very simple, they are defined using //
For example:
// My Comment
Multi-line comments can easily be defined by using /* and closing with */
For example:
/* My Comment 1
My Comment 2
My Comment 3 */
Outputting Text
Output text with PHP is easy. There are also several ways to output text. The simplest way to output text is to use the echo function.
For example:
echo “Example of echo function”;
Variables
Defining variables in PHP is fairly simple.
For example, a simple variable would look like:
$myvar = “My Variable”;
To use a variable, simple use the variable name that you defined, for example:
echo $myvar;
Global Variables
There are pre-defined global variables, such as $_SERVER.
An example outputting a visitor's IP using $_SERVER:
echo $_SERVER['REMOTE_ADDR']; // This outputs the visitor's IP address.
Arrays
Arrays are defined by using the array() function
For example:
$myarray = array(“Array1”, “Array2”);
To use an array:
$myarray['Array1'] = “My Array”;
echo $myarray['Array1'];