PHP | $ vs $$ operator Last Updated : 23 Jul, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The $ operator in PHP is used to declare a variable. In PHP, a variable starts with the $ sign followed by the name of the variable. For example, below is a string variable: $var_name = "Hello World!"; The $var_name is a normal variable used to store a value. It can store any value like integer, float, char, string etc. On the other hand, the $$var_name is known as reference variable where $var_name is a normal variable. The $$var_name used to refer to the variable with the name as value of the variable $var_name. Examples: Input : $Hello = "Geeks for Geeks" $var = "Hello" echo $var echo $$var Output : Hello Geeks for Geeks Input : $GFG = "Welcome to GeeksforGeeks" $var = "GFG" echo $var echo $$var Output : GFG Welcome to GeeksforGeeks Explanation: In the above example, $var stores the value "Hello", so $$var will refer to the variable with name Hello i.e., $Hello. Below program will illustrate the $ and $$ operator in PHP. php <?php // Variable declaration and initialization $var = "Hello"; $Hello = "GeeksforGeeks"; // Display the value of $var and $$var echo $var . "\n"; echo $$var; echo "\n\n"; // Variable declaration and initialization $var = "GFG"; $GFG = "Welcome to GeeksforGeeks"; // Display the value of $var and $$var echo $var. "\n"; echo $$var; ?> Output: Hello GeeksforGeeks GFG Welcome to GeeksforGeeks Comment More infoAdvertise with us Next Article PHP 7 | Spaceship Operator N Naman_Garg Follow Improve Article Tags : Web Technologies PHP PHP-basics Similar Reads PHP Operators In PHP, operators are special symbols used to perform operations on variables and values. Operators help you perform a variety of tasks, such as mathematical calculations, string manipulations, logical comparisons, and more. Understanding operators is essential for writing effective and efficient PH 8 min read PHP Operators In PHP, operators are special symbols used to perform operations on variables and values. Operators help you perform a variety of tasks, such as mathematical calculations, string manipulations, logical comparisons, and more. Understanding operators is essential for writing effective and efficient PH 8 min read PHP 7 | Spaceship Operator This article will make you aware of a very useful operator i.e the spaceship operator PHP 7. The spaceship operator or combined comparison operator is denoted by "". This is a three-way comparison operator and it can perform greater than, less than and equal comparison between two operands. This ope 2 min read PHP 7 | Spaceship Operator This article will make you aware of a very useful operator i.e the spaceship operator PHP 7. The spaceship operator or combined comparison operator is denoted by "". This is a three-way comparison operator and it can perform greater than, less than and equal comparison between two operands. This ope 2 min read PHP | Bitwise Operators The Bitwise operators is used to perform bit-level operations on the operands. The operators are first converted to bit-level and then calculation is performed on the operands. The mathematical operations such as addition , subtraction , multiplication etc. can be performed at bit-level for faster p 5 min read 'AND' vs '&&' as operator in PHP 'AND' Operator The AND operator is called logical operator. It returns true if both the operands are true. Example: php <?php // Variable declaration and // initialization $a = 100; $b = 50; // Check two condition using // AND operator if ($a == 100 and $b == 10) echo "True"; else echo 3 min read Like