A variable variable takes the value of a variable and treats that as the name of a variable.
<html> <head> <title>Creating Variables Variables</title> <meta Name="Author" Content="Hann So"> </head> <body> <p> <?php $helloworld = "Hello World"; $world = "helloworld"; echo "The variable world has a value $world, which becomes a new variable $world. <br /><br />"; echo "<font size=+2 color='blue'>${$world}</font><hr />"; echo "This is another way of creating a variable variable. <br /><br />"; $hello = "Hello"; $$hello = "World"; echo "The variable hello has a value $hello, which becomes a new variable $hello. <br /><br />"; echo "<font size=+2 color='blue'>$hello ${$hello}</font>"; ?> </p> </body> </html> |