Reply to Re: Change variable name

Your name:

Reply:


Posted by Vince Morgan on 04/23/07 10:09

"Boris Savc" <boris.savc@siol.net> wrote in message
news:Xf%Wh.741$553.592020@news.siol.net...
> Sorry for confuzing subject, but that's the thing I'm trying to achieve.
For
> example:
>
> $a = "Hello";
> $b = 1;
>
> I want to change the name of $a to $a1 where 1 is value of variable $b!
>
> Thanks for all the help,
> Boris
>
>
$a = Hello";
$b=1;
if($b==1)
{
$a1=&$b;//creating $a1 as a reference and assigning it's value to the $b
variable.
}
echo $a1;//output is Hello

The code above creates a variable $a1 that is in fact a reference to $a; It
is important to know that if you change the value of $a you will also change
the dereferenced value of $a1, and visa versa. In other words, if you
change the value of $a after the code above you will get the same result
from $a1.
You are not renaming $a actualy. That isn't possible. But you are creating
a variable $a1 that is actualy tied, or bound, to $a. From that point
onward they effectively share the same values and behave as if they are the
same variable.
HTH
Vince

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация