- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the meaning and usage of ‘=&’ assignment operator in PHP?
Instead of copying the data from one variable to another one, the changes made to an array or object can be made to another using the ‘=&’ operator. This is known as the ‘assignment by reference’ method, which means both the values or objects will point to the same data, and no copies of the data are made. This way, data redundancy is avoided.
Example
<?php $my_val1 = 67; $my_val2 = &$my_val1; $my_val1 = 89; print "The value is : "; print "$my_val2"; ?>
Output
The value is : 89
Inside the <php> tags, two values are declared wherein the second value is the assignment by reference of the first value. Next, the value of the first variable is changed and the second value is displayed. It displays the most recently updated value of the first object. This means the changes made to the first variable have reflected in the second variable without making any copies.
- Related Articles
- What is Assignment Operator (=) in JavaScript?
- What is Multiplication Assignment Operator (*=) in JavaScript?
- What is Addition Assignment Operator (+=) in JavaScript?
- What is an assignment operator in C#?
- Reference assignment operator in PHP to assign a reference?
- What is Bitwise OR Assignment Operator (|=) in JavaScript?
- What is Bitwise XOR Assignment Operator (^=) in JavaScript?
- What is the usage of in operator in JavaScript?
- What is vertical bar in Python bitwise assignment operator?
- Explain the concept of logical and assignment operator in C language
- What's the difference between assignment operator and copy constructor in C++?
- Java Assignment Operator Examples
- Difference Between Copy Constructor and Assignment Operator in C++
- Explain about add and assignment(+=) operator in detail in javascript?
- Copy constructor vs assignment operator in C++

Advertisements