Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Meaning of $$ variable

Status
Not open for further replies.

Edward999

Programmer
Joined
Dec 26, 2002
Messages
112
Location
MY

Hi I'm new to PHP. I need to know the meaning of $$variable.

My source code as below:


foreach($template_field as $key => $val) {

$varname[] = $namevar = "template$key";

$$namevar = $valuez;}

Why we use $$namevar?....Please help

Thanks in Advance

edward
 
Code:
$varname = "myVar";
$value = 5;

# now watch:
$$varname = $value;

echo $myVar;
# output will be: 5

By using the $$ sign you assigned a value to a variable that itself comes from a variable. Ok?
 

Thanks a million everyone.

edward
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top