Why does PHP use a dollar sign $ to prefix variables?

Rasmus Lerdorf, the father of the PHP language, explains the $ sign as an ability to insert variables inside literal string values (interpolation), so that the variables are distinguished from the rest of the string. A dollar sign in front of variables in PHP is inspired by Perl which greatly influenced PHP during its early years.

Many other programming languages also use a dollar sign in their syntax. This symbol is called “sigil” and simplifies interpolation.

Names not prefixed by $ are considered constants, functions, class names, etc.

Sigil usage simplifies the variable interpolation into strings:

<?php

$name = "World";
echo "Hello, $name";

Where as in languages without sigil usage (for example, Python), you must either concatenate strings:

# Python
name = "World"
print "Hello, " + name

or use special interpolation syntax if the language provides it. For example, Ruby:

# Ruby
name = "World"
puts "Hello #{name}"

Many people used to other languages might find the sigil usage odd, but you can get used to it in no time and discover its benefits.

See also