is a special variable that can hold many values under a single name, and you can access the values by referring to an index number or index name.
Array
stores multiple values in one single variable.
Array
Three ttypes of arrays
Indexed Arrays
Associative Arrays
Multidimensional Array
Arrays with a numeric index
Indexed Arrays
Arrays with named keys
Associative Arrays
Arrays containing one or more arrays
Multidimensional
its items can be of any data type.
Array
The most common are strings and numbers (int, float), but ______ items can also be objects, functions or even arrays.
Arrays
each item has an index number
Indexed Array
By default, the first item has index 0, the second item has item 1, etc.
Indexed Array
To access an array item, you can refer to the _____ _____.
index number
To change the value of an array item, use the _____ _____
index number
To loop through and print all the values of an indexed array, you could use a ________
foreach loop.
are arrays that use named keys that you assign to them.
Associative Arrays
To access an associative array item you can refer to the ______ ____
Key name
To change the value of an associative array item, use the ____ _____.
Key name
To loop through and print all the values of an associative array, you could use a ____ ____
foreach loop.
were introduced in PHP 4.1.0, and are built-in variables that are
always available in all scopes.
SUPERGLOBALS
Some predefined variables in PHP are “superglobals”, which means that they are always accessible, regardless of scope - and you can access them from any function, class or file without having to do anything special.
SUPERGLOBALS
What are the superglobal variables
$GLOBALS
$_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION
is an array that contains all global variables.
$GLOBALS
are variables that can be accessed from any scope.
Global Variables
Variables of the outermost scope are automatically ____ _____, and can be used by any scope, e.g. inside a function.
Global Variables
To use a global variable inside a function you have to either define them as global with the global keyword, or refer to them by using the _______ syntax.
$GLOBALS