PHPPHP8 min read

Variables and Data Types in PHP

Understand variables, strings, numbers, booleans, and how PHP handles types.

Sophia Miller
November 17, 2025
3.3k81

Variables store data. In PHP, they always start with a $ sign.

Creating variables

<?php
$name = "John";
$age = 25;
$isStudent = true;
?>

Common data types

  • string: "Hello"
  • integer: 10
  • float: 3.14
  • boolean: true / false
  • array: list of values
  • null: no value

Using variables

<?php
echo "My name is $name and I am $age years old.";
?>

PHP replaces variables inside double quotes.

Type checking

var_dump($age);

Shows type and value.

Next: Operators and basic math in PHP.

#PHP#Variables#Beginner