PHP data types:

  • String

  • Integer

    • Non-decimal number between -2,147,483,648 and 2,147,483,647​​​
    • Must have at least one digit
    • Must not have a decimal point
    • Can be either positive or negative
    • Can be specified in three formats:
      • decimal (10-based),
      • hexadecimal (16-based - prefixed with 0x) or
      • octal (8-based - prefixed with 0)
  • Float (aka double)

    • ​​Number with a decimal point or a number in exponential form​
  • Boolean

    • TRUE or FALSE​

  • Array

    • ​​Stores multiple values
  • Object

    • ​​​Stores data and information on how to process that data.​
  • NULL

    • ​​Has no value assigned to it.​
    • If a variable is created without a value, it is automatically assigned a value of NULL.
  • Resource

    • Reference to functions and resources external
    • This is not an actual data type
    • e.g. database call

var_dump() function returns the data type and value

<?php 
$x = "Hello world!";
$y = 'Hello world!';

echo $x;
echo "<br>"; 
echo $y;
?> 

<?php 
$x = 5985;
var_dump($x);
?>

<?php 
$x = 10.365;
var_dump($x);
?>

<?php 
$x = true; 
$y = false;
?>

<?php 
$cars = array("Volvo","BMW","Toyota");
var_dump($cars);
?>

<?php
$x = "Hello world!";
$x = null;
var_dump($x);
?>