17 – Difference Between $ and $$ in PHP

Difference Between $ and $$ in PHP

This tutorial will focus on the difference between $ and $$ PHP To start with, let’s review first what is PHP Variables.

PHP Variable plays a vital role in PHP programming. It allows you to store information in computer memory.

To declare a PHP variable, it starts with a dollar sign($) like as shown in the syntax below

PHP Variable Syntax:

$$ Meaning in PHP (Double Dollar Variable)

The PHP $$ (double dollar) variable is a reference variable that stores the value which is accessible by using $ Symbol(Single Dollar) variable value

They call it sometimes as a variable variable name. Wherein the variable name can be set and used dynamically.

Below examples illustrate the use of $ and $$ in PHP

[su_box title=”Output Will Be:” radius=”7″ ]PHP[/su_box]

Here’s the $$ in PHP Example

[su_box title=”Output Will Be:” radius=”7″ ]



Another Complex Example of $$ in PHP

[su_box title=”Output Will Be:” radius=”7″ ]

Is Fun!
Is Fun!


We will discuss what we have in the above code using PHP Double dollar and Dollar Variables

  1. First, we declare and initialize the variable.
  2. Then, reference the variable
  3. Next, we use the double reference variable
  4. Finally, we display the value of the variable.
  5. Lastly, we display a double reference.


If you have any questions about the $$ in PHP example, please feel to contact us or simply leave a comment below.


Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.