Mark As Completed Discussion

#2 - PHP Data Types

PHP Data Types Introduction

There are eight fundamental data types in PHP. Here’s an overview of these eight types.

Data TypesDescriptionExample
StringA sequence of characters inside quotes“Hello World”
BooleanA boolean represent two states: true/falsetrue false
NULLShows absence of a value. An unassigned variable has the value null$a; // variable a is null
ArrayAn array stores multiple values in a single variable[1,2,3,4,5,6,7,8,9,10]
IntegerAn integer represents a non-decimal number100 -2 2000 1
DoubleA double represents decimal or numbers in exponential form3.14159 22.6 -3.1
ObjectAn instance of a class that inherits its attributes and methods$person = new Person()
ResourceA resource data type is a reference to an external resource like a file or databaseDatabase call
PHP
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment