- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
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
- Related Articles
- How to assign a reference to a variable in C#
- Can we assign a reference to a variable in Python?
- Is it possible to assign a reference to "this" in java?
- Reference and dereference operator in Arduino
- PHP Passing by Reference
- PHP Return by Reference
- How to pass reference parameters PHP?
- How to change/convert absolute reference to relative reference in Excel?
- Differences between Method Reference and Constructor Reference in Java?
- How do you pass objects by reference in PHP 5?
- What is the difference between a weak reference and an unowned reference?
- What is the meaning and usage of ‘=&’ assignment operator in PHP?
- What is Pass By Reference and Pass By Value in PHP?
- How to add a resource reference in HTML?
- Olfactory Reference Syndrome