- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
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