Variables always start with the dollar sign followed by the variable name:
$today = “Friday, April 11 2025”; // this is a string variable
$price = 023.04; // this is a float (floating point number)
$quantity = 12; // this is an integer
$taxable = true; // this is a boolean
Rules for PHP variables:
1. A variable starts with the $ sign, followed by the name of the variable
2. A variable name must start with a letter or the underscore character
3. A variable name cannot start with a number
4. A variable name can only contain alpha-numeric characters and underscores
5. Variable names are case-sensitive ($age and $AGE are two different variables)
Arrays: an Array can be defined like this:
$myarray=array(‘Value1′,’Value2′,’Value3’); // $myarray contains 3 strings
Adding to an array is done like this:
$myarray[]=”John Jones”; // $myarray contains 4 strings
$myarray[]=”Mary Smith”; // $myarray contains 5 strings
Now $myarray contains 5 entries.
They can also be defined like this:
$myarray=array(); // produces an empty array
The PHP superglobal variables are:
1 $GLOBALS
2 $_SERVER
3 $_REQUEST
4 $_POST
5 $_GET
6 $_FILES
7 $_ENV
8 $_COOKIE
9 $_SESSION
Origins 2008 – The Fork Begins MySQL AB had been acquired by Sun Microsystems in…
Useful functions built into PHP You can display the entries in an array with the…
WampServer, a Windows web development environment. This only runs on Windows computers but it is…
XAMPP a local environment for web development. Setting up XAMPP (which stands for X (Cross-Platform),…
This will get you started writing in PHP. Just go to w3schools.com and click on…
MySQL was created in 1994 by Swedish developers David Axmark and Allan Larsson, along with…
View Comments