Voting

Please answer this simple SPAM challenge: nine minus two?
(Example: nine)

The Note You're Voting On

zzo38
8 years ago
You can make references like pointers. Example:
<?php
  $a
=6;
 
$b=array(&$a); // $b is a pointer to $a
 
$c=array(&$b); // $c is a pointer to $b
 
$d=7;
 
$c[0][0]=9; // $a is 9
 
$c[0]=array(&$d); // $b is a pointer to $d
 
$c[0][0]=4; // $d is 4
 
$b=array(&$a); // $b is a pointer to $a again
 
echo $a.$b[0].$c[0][0].$d; // outputs 9994
?>
These kind of pointers may even be passed to functions or returned from functions, copied and stored in multiple arrays/variables/objects, etc.

<< Back to user notes page

To Top