Variable Variables

If you're ever in need to create dynamic PHP variables names, you're going to need to use what is called variable reflection. This opens many possibilities with PHP, and can be used many ways. To explain, in simple terms :

# The first variable is a standard variable assignment.
$variable = "Color";

# The second variable is defined by reflecting the first variable.
$$variable = "Green";

$Color == "Green";

Find this article helpful?

Consider becoming a fan of our Facebook page! The link is in our fan box on the left!