<?php $a = 1; $b =& $a; $c = 2; $d = 3; $e = array($a); function is_reference($var){ $val = $GLOBALS[$var]; $tmpArray = array(); foreach($GLOBALS as $k => $v){ if(!is_array($v)){ $tmpArray[$k] = $v; } } foreach($GLOBALS as $k => $v){ if($k != 'GLOBALS' && $k != '_POST' && $k != '_GET' && $k != '_COOKIE' && $k != '_FILES' && $k != $var && !is_array($v) ){ usleep(1); $GLOBALS[$k] = md5(microtime()); } } $bool = $val != $GLOBALS[$var]; foreach($tmpArray as $k => $v){ $GLOBALS[$k] = $v; } return $bool; } var_dump(is_reference('a')); var_dump(is_reference('b')); var_dump(is_reference('c')); var_dump(is_reference('d')); ?>
This is an example from the PHP documentation .
source share