PHP Datatypes Flashcards
7 data types
- integers
- floats
- strings
- arrays
- booleans
- objects
- resources (anything that isn’t PHP data)
T/F: A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script. A constant is case-sensitive by default. By convention, constant identifiers are always uppercase.
True
Create Two Integer Variables - The first will be named $integer_one with a value of 1 and the second will be named $integer_two with a value of 2
Now Let’s Create A Float. Create A Float Variable Named $golden And Set Its Value To 1.618
Create a boolean variable named $bool and make it evaluate to true.
$integer\_one = 1; $integer\_two = 2; $golden = 1.618; $bool = true;
Create An Empty Array Named $colors.
Add three colors to your array: ‘red’, ‘blue’, & ‘green’
Now using the $colors array, echo the second value.
Time to add an associative array named $favorite_colors. The keys will be, in order, the following: ‘mike’, ‘jane’, & ‘chris’ with values for each. Those values are ‘green’, ‘blue’, & ‘yellow’
$colors = array(‘red’, ‘blue’, ‘green’);
echo $colors[1];
$favorite_colors = array (
‘mike’ => ‘green’,
‘jane’ => ‘blue’,
‘chris’ => ‘yellow’
);