Pointers and references: Difference between revisions
Content added Content deleted
(→{{header|PARI/GP}}: add note on Pari) |
|||
Line 560: | Line 560: | ||
my $arrayref = ['an', 'array']; |
my $arrayref = ['an', 'array']; |
||
my $hashref = { firstkey => 'a', secondkey => 'hash' }</lang> |
my $hashref = { firstkey => 'a', secondkey => 'hash' }</lang> |
||
=={{header|PHP}}== |
|||
Actual Reference or Pointer "objects" don't exist in PHP, but you can simply tie any given variable or array value together with the "=&" operator. |
|||
<lang php><?php |
|||
/* Assignment of scalar variables */ |
|||
$a = 1; |
|||
$b =& $a; // $b and $a are now linked together |
|||
$b = 2; //both $b and $a now equal 2 |
|||
$c = $b; |
|||
$c = 7; //$c is not a reference; no change to $a or $b |
|||
unset($a); //won't unset $b, just $a. |
|||
?></lang> |
|||
===See Also=== |
|||
* [http://php.net/manual/en/language.references.php php.net:References Explained] |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |