- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 −
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 −
<!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>
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
- How to assign a reference to a variable in C#
- Can we assign a reference to a variable in Python?
- PHP Passing by Reference
- PHP Return by Reference
- Reference and dereference operator in Arduino
- How to pass reference parameters PHP?
- Is it possible to assign a reference to "this" in java?
- Differences between Method Reference and Constructor Reference in Java?
- How do you pass objects by reference in PHP 5?
- How to add a resource reference in HTML?
- The OSI Reference Model
- Java Assignment Operator Examples
- Reference Models in Computer Network
- What is a reference variable in C++?
- Defining a variable reference in SAP ABAP