 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Reference assignment operator in PHP to assign a reference?
Let’s say we have the following value −
$nextValue=100;
Let us take a new variable and assign a reference −
$currentValue = &$nextValue;
To assign a reference, use the reference assignment operator i.e. =&$anyVariableName in PHP.
The PHP code is as follows −
Example
<!DOCTYPE html> <html> <body> <?php $nextValue=100; $currentValue = &$nextValue; echo "Next Value=",$nextValue,"<br>"; echo "Current Value=",$currentValue,"<br>"; $nextValue = 45000; echo "After changing the value of next will reflect the current value because of =&","<br>"; echo "Next Value=",$nextValue,"<br>"; echo "Current Value=",$currentValue; ?> </body> </html>
Output
Next Value=100 Current Value=100 After changing the value of next will reflect the current value because of => Next Value=45000 Current Value=45000
Advertisements
 