Skip to content
  • About Us
  • Contact Us
  • Privacy Policy
  • Disclaimer
  • Corona Virus Stats (Covid-19)
  • Work with us
  • FB
  • LinkedIn
  • Twitter
  • Instagram.com
Tekraze

Tekraze

Dive Into Technology

  • Guides
    • Developer Guide
    • PC Guide
    • Web Guide
    • Android Guide
    • Music
    • Tutorials
  • Feed
    • Tech News
    • Shared Tech
    • Gaming Videos
    • Unboxing videos
  • Forums
    • Android Apps
    • Angular Npm Packages
    • Useful Site Links
    • Tech Queries
    • Windows OS Help
    • Web Guide and Help
    • Android Os And Rooting
    • Jhipster Discussion
    • Git & GitHub forum
    • Open Source Forum
  • Work with us
  • Toggle search form
  • unsexy startups tekraze
    Unsexy Startups disrupting Trillion Dollar Industries Shared Tech Posts
  • Alphabet of programming ;languages
    The Alphabet of Programming Languages Tech News
  • Phone System for small businesses shown
    Best phone systems for small businesses a handy guide Tutorials
  • AI or artificial intelligence a contribution to a better future or just another trend?
    AI: a contribution to a better future or just another trend? Latest tech
  • Serey Blockchain and Trading Contest on Coinsbit Banner
    Serey Blockchain and Trading contest on Coinsbit in 2022 Tech News
  • What makes electrostatic headphones different from other headphones
    What makes electrostatic headphones different from other headphones? Music
  • Realme Narzo 10 Tekraze
    Realme Narzo 10 and Narzo 10A Launched Tech News
  • Windows 10 New Features 1
    Windows 10 New Features PC Guide
Reference Variable in PHP 2

Reference Variable in PHP

Posted on March 10, 2018March 11, 2018 By RAHUL CHANANA No Comments on Reference Variable in PHP

We have learned in the last tutorial, about Variable and its scope in PHP. Now, we will discuss some examples of variables and Data Types in PHP. But before that, if you have not seen the previous posts How to install PHP & Variable & its Scope in PHP, Please have a look at that first, and then continue with this post.

PHP $ and $$ Variables

What is $ variable or $$ variable?

  • The $var is a var variable created with single dollar is an ordinary variable, with the name var that stores any value like string, integer, float, etc.
  • The $$var double dollar is a reference variable that stores the value of the $variable inside it.

It allows you to have “Variables variable”, i.e., The string stored in normal variable allow users to create variable whose name is dynamic

To better understand consider this simple example:-

<?php

$blog=”Tekraze”;
$$blog=”Rahul CHANANA”;
echo $blog.” “;
echo $$blog.” “;
echo $Tekraze;

?>

OUTPUT:

Tekraze
Rahul CHANANA
Rahul CHANANA

In the above example,

  • $blog is just a variable with string value=“Tekraze”.
  • $$blog is reference variable . $$blog uses the value referenced by the variable $blog,
  • echo $blog print the value: Tekraze
  • echo $$blog print the value: Rahul CHANANA  value of this $blog variable is act as reference of second variable $$blog.
  • echo $Tekraze print the value : Rahul CHANANA,  Here $Tekraze also act as reference variable.

Let’s take an another example now using $ ,$$ and $$$

<?php

$name=“Haryana”;${$name}=“Chandigarh”;
${${$name}}=“Hisar”;
echo $name. “<br>”;
echo ${$name}. “<br>”;
echo $Haryana. “<br>”;
echo ${${$name}}. “<br>”;
echo $Chandigarh. “<br>”;

?>

OUTPUT:

Haryana
Chandigarh
Chandigarh
Hisar
Hisar

In the above example, we have assigned a value to the variable name Haryana. Value of reference variable ${$name} is assigned as Chandigarh and ${${$name}} as Hisar.

Now we have printed the values as $name, ${$name}, $Haryana, ${${$name}} and $Chandigarh.

So this is for today, in our next tutorial we will learn about Data Types in PHP. Stay connected with us for more tutorials.

If you like this tutorial please share it with your friends, colleagues and with your relatives, keep visiting and be a part of the Tekraze family. If you have any problem with this tutorial please comment in the comment box and if you have any suggestion regarding this then please tell us.

Content Protection by DMCA.com
PHP Tutorials Tags:$ and $$ variable, Variables in PHP

Post navigation

Previous Post: Biggest Innovation Since internet – Blockchains
Next Post: Backend Technologies – 2018

Related Posts

  • PHP-Operators 3
    PHP-Operators PHP Tutorials
  • Develop Mobile Apps with PHP & Have Some Kik in Life 4
    Develop Mobile Apps with PHP & Have Some Kik in Life Developer Guide
  • Introduction to PHP 5
    Introduction to PHP Web Guide
  • How to Install PHP XAMPP 6
    How to Install PHP XAMPP PHP Tutorials
  • PHP Data Types 7
    PHP Data Types PHP Tutorials
  • Variable & its Scope in PHP 8
    Variable & its Scope in PHP Developer Guide

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Advertisements

Subscribe to updates

Enter your email below to subscribe





Posts by Categories

Advertisements
  • system integration tekraze
    What are the Types of System Integration? Guest posts
  • How to get a chinese phone number banner
    How to Get a Chinese Phone Number? Web Guide
  • It trends to look for in 2019 tekraze
    6 Game Changing Enterprise IT Trends you must know Developer Guide
  • Create Sticker Application for Whatsapp
    How to Create Stickers Application for Whatsapp Developer Guide
  • Photoshop Basics Tutorials 9
    Photoshop Basics Tutorials Web Guide
  • Linux Terminology basics you need to know
    Developer Terminology – you need to know Developer Guide
  • Cloud Gaming Services Banner
    13 cloud gaming services for gamers to play high end games in 2021 Gaming
  • Realme 6 Pro Tekraze
    Realme 6 and Realme 6 Pro – Launched Tech News

Affliate Links

Sell with Payhip

Earn with Magenet

Sell and Buy with Adsy

GainRock affiliate Program

Automatic Backlinks

Advertise with Anonymous Ads

accessily tekraze verificationIndian Blog Directory

Copyright © 2023 Tekraze.

Powered by PressBook News WordPress theme