Jump to content

double dollar sign meaning


webguync

Recommended Posts

<?

$myprice = 10.00;

$item = $myprice;

 

$$myprice = 20.00;

echo "the value of \$\$myprice is" . $$myprice;

?>

 

output is 'the value of $$myprice is20'

 

$numberofnames = 10;

if you have fields with names like name1, name2, name3 etc. you could

for ( $i = 1; $i <= $numberofnames; $i++) {

  $t = "name$i";

echo $$t . "<br>" ;

}

 

or

<?

$numberofnames = 10;

$name1 = "my string here";

#if you have fields with names like name1, name2, name3 etc. you could

for ( $i = 1; $i <= $numberofnames; $i++) {

  $t = "name$i";

  echo $$t ;

 

 

}

?>

yields output 'my string here'

 

 

 

so there is some relevance to using it if you have to iterate thru values that have similar names

or possibly associate arrays?

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.