Field Manual PHP / Laravel reference
← PHP

Variables

Variables begin with $ and can hold different values over time.

What it is

Variables begin with $ and can hold different values over time.

When to use it

Use clear names and initialize values before reading them.

Syntax

$name = "Ada";
$count = 0;

Example

$reference = "ORD-001";
$isPaid = false;
$metadata = ["reference" => $reference];

Common mistakes

Undefined variables are warnings; avoid variable variables from untrusted input.

Related topics

Environment variables