PHP Datatypes Flashcards

1
Q

7 data types

A
  • integers
  • floats
  • strings
  • arrays
  • booleans
  • objects
  • resources (anything that isn’t PHP data)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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.

A
$integer\_one = 1;
$integer\_two = 2;
$golden = 1.618;
$bool = true;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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’

A

$colors = array(‘red’, ‘blue’, ‘green’);
echo $colors[1];
$favorite_colors = array (
‘mike’ => ‘green’,
‘jane’ => ‘blue’,
‘chris’ => ‘yellow’
);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly