Data Types in PHP Flashcards
What defines the type of data a variable can store in PHP?
Data Types
PHP allows eight different types of data types.
How many simple data types are there in PHP?
Five
The first five data types are called simple data types.
What is an Integer in PHP?
Whole numbers, both positive and negative
Example: $age = 25;
What is a Float (Double) in PHP?
Numbers with decimal points
Example: $price = 19.99;
What does the NULL data type represent in PHP?
A special type that can hold only one value, i.e., NULL
Example: $var = NULL;
What is a String in PHP?
A sequence of characters enclosed in quotes
Example: $name = ‘John Doe’;
What values can a Boolean hold in PHP?
TRUE or FALSE
Example: $isActive = true;
What is an Array in PHP?
A compound data type that can store multiple values of the same data type
Example: $fruits = array(‘Apple’, ‘Banana’, ‘Cherry’);
What are Objects in PHP?
Instances of user-defined classes that can hold both values and functions
Objects allow encapsulation of data and behavior.
What are Resources in PHP?
Not an exact data type; used to store references to function calls or external PHP resources
Example: Consider a database call.