Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • PHP Tutorial
  • PHP Exercises
  • PHP Array
  • PHP String
  • PHP Calendar
  • PHP Filesystem
  • PHP Math
  • PHP Programs
  • PHP Array Programs
  • PHP String Programs
  • PHP Interview Questions
  • PHP GMP
  • PHP IntlChar
  • PHP Image Processing
  • PHP DsSet
  • PHP DsMap
  • PHP Formatter
  • Web Technology
Open In App
Next Article:
Difference between PHP and C#
Next article icon

Difference between $var and $$var in PHP

Last Updated : 18 Oct, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

In PHP, $var is used to store the value of the variable like Integer, String, boolean, character. $var is a variable and $$var stores the value of the variable inside it.

$var:

Syntax:

$variable = value;
  • The $variable is the variable name
  • The value is the initial value of the variable.

Example 1: This example stores and displays values with $.

PHP
<?php          // String value        $value1 = "hello Geeks";         // Display string value     echo $value1;      echo "<br/>";      // Boolean value     $value2 = true;                 // Display boolean value     echo $value2;       echo "<br/>";      // Integer value     $value3 = 34;          // Display integer value     echo $value3;      echo "<br/>"; ?> 
 

Output
hello Geeks<br/>1<br/>34<br/>

$$var: $$var stores the value of $variable inside it.

Syntax:

$variable = "value";    $$variable = "new_value";
  • $variable is the initial variable with the value.
  • $$variable is used to hold another value.

We can get another value by using the $value of the first variable.

Example 2: PHP program to demonstrates $$var.

PHP
<?php         // String value       $value1 = "hello";           // Display string value       echo $value1;         echo "\n";        // Store another string in $$var       $$value1 = "Hello php";      // Access another string using     // value of $var       echo "$hello"; ?> 

Output
hello  Hello php

Difference between Both: The variable $var is used to store the value of the variable and the variable $$val is used to store the reference of the variable.


Next Article
Difference between PHP and C#
author
sravankumar_171fa07058
Improve
Article Tags :
  • Difference Between
  • Web Technologies
  • PHP
  • PHP-basics
  • PHP-Questions
  • Web Technologies - Difference Between

Similar Reads

  • What's the difference between and in PHP ?
    There are many types of line-ending characters that are used in PHP. They differ depending upon the operating system and editors using them. It's also based on how apps, libraries, protocols, and file formats deal with things. These characters are invisible. \n is used for the newline or linefeed, w
    2 min read
  • What is the difference between == and === in PHP ?
    In this article, we will discuss the differences between '==' and '===' operators in PHP. Both are comparison operators used to compare two or more values. == Operator: This operator is used to check the given values are equal or not. If yes, it returns true, otherwise it returns false. Syntax: oper
    2 min read
  • Difference Between JSP and PHP
    JSP was an implies of giving a comparable programming fashion to PHP and ASP. It is based on Java Servlets and requires a Servlet holder server like Tomcat to supply the backend preparation required to change over the JSP to a servlet that can yield HTML. In differentiating PHP can run on its posses
    4 min read
  • Difference between var and let in JavaScript
    In the early days of JavaScript, there was only one way of declaring variables and that was using the var keyword. A variable declared with var is defined throughout the program. One of the issues with using the var keyword was redeclaring a variable inside a block will also redeclare the variable o
    3 min read
  • Difference between PHP and C#
    PHP is the recursive acronym for Hypertext Preprocessor. It is the widely-used general-purpose scripting language that is especially used for web development and embedded into the HTML. Its scripts are executed on the server. Files of PHP contains HTML, CSS, JavaScript and PHP code. It is executed o
    2 min read
  • Difference Between Golang and PHP
    Golang is a statically typed, compiled programming language invented at Google headquarter by Mr. Robert Griesemer, Mr Rob Pike, and Mr. Ken Thompson. Its development began in 2007 and it was made available to the public in the year 2009. It's open-source and freely available for public use. It is m
    2 min read
  • Difference between C++ and PHP
    1. C++ : C++ was developed by Bjarne Stroustrup at Bell Labs since 1979 as an extension of the C language C++ is a general purpose programming language and widely used now a days for competitive programming. It has imperative, object-oriented and generic programming features. C++ is a widely popular
    2 min read
  • Difference between Java and PHP
    Java is a very famous object-oriented programming language. It was developed by Sun Microsystems. It has a virtual machine platform that allows you to create compiled programs that run on nearly every platform. Java promised, “Write Once, Run Anywhere”. It has a continuous contribution from industry
    2 min read
  • What is the difference between Perl and PHP ?
    PHP: PHP (Hypertext Pre-processor) is a general-purpose programming language used to designed a website or web applications. It is the server-side scripting language embedded with HTML to develop Static website, Dynamic website or Web applications. It is used to interact with database and display th
    2 min read
  • Difference between require() and include() in PHP
    In this article, we will see the require() and include() Functions in PHP, along with understanding their basic implementation through the illustration. Both require() and include() Functions are utilized to add the external PHP files in the current PHP script. With this, both functions enhance the
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences