
- 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
PHP Unsetting References
Introduction
It is possible to break binding between the content and variable by using unset() function. The unset() function doesn't destroy the content but only decouples variable from it.
Example
<?php $a=10; $b=&$a; echo "before unsetting : ", $a, " " ,$b, PHP_EOL; unset($b); echo "after unsetting :" . $a . " "; $b=20; echo $b; ?>
Output
After unsetting, $b can be used as normal vaiable
before unsetting : 10 10 after unsetting : 10 20
Reference can also be removed by assigning variable to NULL
Example
<?php $x=100; $y=&$y; echo "x and y are references ", $x, " " ,$y, PHP_EOL; $y=NULL; $x=200; echo "x: ", $x . " y: " ,$y, PHP_EOL; ?>
Output
Result of above script is as follows
x and y are references 100 x: 200 y:
- Related Articles
- PHP References
- PHP Spotting References
- PHP Objects and references
- Examples of soft references and phantom references?
- Python Weak References
- References in C++
- Create References in Perl
- Circular References in Perl
- Pointers vs References in C++
- References to Functions in Perl
- Types of References in Java
- Video.js Player Method / Options References
- Back references in Java regular expressions
- What are circular references in C#?
- What are method references in Java8?

Advertisements