PHP Classes

PHP Reference Variable Debug: Check if a variable is a reference to another one

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 126 This week: 1All time: 9,407 This week: 560Up
Version License PHP version Categories
refdebug 1.0.1Custom (specified...5PHP 5, Debug, Language
Description 

Author

This class can check if a variable is a reference to another one.

It can take a given variable and determines if it is an actual variable or a reference to another variable.

The class can also get the number of references that point to a given variable.

Innovation Award
PHP Programming Innovation award nominee
October 2018
Number 11
In PHP variables can contain values of a specific type, or can be references pointing to other values.

This package can not only determine if a variable is a reference to another, but can also determine the number of references that point to a given variable.

Manuel Lemos
Picture of zinsou A.A.E.Moïse
  Performance   Level  
Name: zinsou A.A.E.Moïse is available for providing paid consulting. Contact zinsou A.A.E.Moïse .
Classes: 50 packages by
Country: Benin Benin
Age: 34
All time rank: 6781 in Benin Benin
Week rank: 109 Up1 in Benin Benin Equal
Innovation award
Innovation award
Nominee: 23x

Winner: 2x

Example

<?php
require_once('Reference.class.php');
echo
'<pre>';

$R=39;
$c=25;
$T=39;
$U=39;
$I=39;
$poiur=&$R;

$d=&$c;

class
foo {
    private
$a=8;
    public
$b = 1;
    public
$c;
    private
$d;
    static
$e;
    public function
__construct(&$c){
       
$this->c=&$c;
    }
    public function
test() {
       
var_dump(get_object_vars($this));
    }
}

$test = new foo($c);


var_dump(Reference::is(get_defined_vars(),$c,$num),$num);
var_dump(Reference::is(get_defined_vars(),$c,$num),$num);

function
testify(){
   
$y=2;
   
$x=[5,1,3,[&$y]];
   
var_dump(Reference::is(get_defined_vars(),$x[3][0],$num),$num);
}

testify();

Reference::dump(get_defined_vars(),$c);
?>


Details

PHP Reference Debug is a very simple class providing static methods to check whether or not a variable is a reference .It also allows to get a a more precise value of the reference count than the PHP debug_zval_dump.The package is written in pure PHP and has no dependency. Remarks: the first argument of the methods must always be get_defined_vars to really and properly defined the scope of the checked variable.(see the how to use example) Bug reporting to leizmo@gmail.com or in the forum.

  Files folder image Files  
File Role Description
Accessible without login Plain text file license.txt Lic. license file
Accessible without login Plain text file readme.txt Doc. readme
Plain text file Reference.class.php Class class source
Accessible without login Plain text file testRefDebug.php Example example script

 Version Control Unique User Downloads Download Rankings  
 0%
Total:126
This week:1
All time:9,407
This week:560Up