
- 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 Spotting References
Introduction
Many syntax constructs in PHP are implemented via referencing mechanisms. If reference to a global variable is unset in a function, the same variable in global namespace is not removed.
Example
<?php $var1 = 'Hello World'; function myfunction(){ global $var1; $var2 =&$var1; echo "$var1, $var2
"; $var2="Hello PHP"; echo "$var1, $var2
"; unset($var1); } myfunction(); echo "$var1
"; ?>
Output
Global $va1 is intact.
Hello World, Hello World Hello PHP, Hello PHP Hello PHP
debug_zval_dump() function can be used if a variable has references to other variables
- Related Articles
- PHP References
- PHP Unsetting References
- PHP Objects and references
- Difference Between Period and Spotting
- Spotting Between Periods: Should You Worry?
- 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
- What are method references in Java8?
- Back references in Java regular expressions

Advertisements