Home > Archive > PHP DB > February 2007 > Re: [PHP-DB] Strange action with =&
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PHP-DB] Strange action with =&
|
|
|
| Peter Beckman wrote:
> Because I'm trying to point out a problem with PHP, where setting a
> reference when the other side is undefined or not set, PHP creates a
> reference to a previously non-existent array item, just by setting a
> reference. I don't think that should happen.
>
And? what's wrong with that. The reference can be used in the future - I
think thats why it doesnt produce any error message.
ie.
$array=array("1"=>"a","3"=>"c");
$ref=&$array["2"];
$array["2"]="b";
echo($ref);
OKi98
| |
| Haydar Tuna 2007-02-20, 7:57 am |
| Hello
This (=&) is used in the variable references. in $ref=&$array["2"] line
$ref variable and $array["2"] variable point at the same address. if you
assign any value to this any variables, both of them will change their
values because echo($ref) line display b on the screen.
--
Haydar TUNA
Republic Of Turkey - Ministry of National Education
Education Technology Department Ankara / TURKEY
Web: http://www.haydartuna.net
"OKi98" <oki98@centrum.cz> wrote in message
news:45D184C0.2060208@centrum.cz...
> Peter Beckman wrote:
>
> And? what's wrong with that. The reference can be used in the future - I
> think thats why it doesnt produce any error message.
> ie.
> $array=array("1"=>"a","3"=>"c");
> $ref=&$array["2"];
> $array["2"]="b";
> echo($ref);
>
>
> OKi98
|
|
|
|
|