note 98801 modified in language.references.arent by danbrown
| From: | danbrown@php.net | Date: | Thu, 08 Jul 2010 16:26:42 +0000 |
| Subject: | note 98801 modified in language.references.arent by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-170796@lists.php.net to get a copy of this message | ||
I understand this like that:
ãThe reference in PHP is like creating single pointer at own variable in C/C++ and point at
variable ( without pointers arithmetic and we can't get number of variable address in memory).
For example
<?php
$a = 4;
$b = &$a;
$c = &$b;
echo "$a - $b - $c<br>";
// 3 pointers ( a , b , c) point at memory location where stored value of number is 4.
$c = 5;
echo "$a - $b - $c<br>";
// all variables equals 5;
unset($a);
$c = 6;
echo "$a - $b - $c<br>";
//$a is not exist but it was only pointer ( not real part of memory) so we have to way to get value
or change it
?>
----
When we want create some "pointer of pointer" in PHP i can't do that because
it's impossible in PHP. We need pointer to another pointer to change the place that the pointer
refers to. In your exaple you just change value of variable in function. ( no operation of pointers
)
--was--
I understand this like that:
ãThe reference in PHP is like creating single pointer at own variable in C/C++ and point at
variable ( without pointers arithmetic and we can't get number of variable address in memory).
For example
<?
$a = 4;
$b = &$a;
$c = &$b;
echo "$a - $b - $c<br>";
// 3 pointers ( a , b , c) point at memory location where stored value of number is 4.
$c = 5;
echo "$a - $b - $c<br>";
// all variables equals 5;
unset($a);
$c = 6;
echo "$a - $b - $c<br>";
//$a is not exist but it was only pointer ( not real part of memory) so we have to way to get value
or change it
?>
----
When we want create some "pointer of pointer" in PHP i can't do that because
it's impossible in PHP. We need pointer to another pointer to change the place that the pointer
refers to. In your exaple you just change value of variable in function. ( no operation of pointers
)
http://php.net/manual/en/language.references.arent.php