1

How does php handle something like this...

$blah = "Testing a variable"; 
$$blah = "test"; 

What would my new variable name be?

Dalton Conley
  • 1,599
  • 2
  • 28
  • 36

4 Answers4

9

Everything you need to know about variable variables at http://www.php.net/manual/en/language.variables.variable.php, except for one thing: don't use them.

Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151
4

echo ${'Testing a variable'};

However, you don't want to do this in practice. It makes for unmaintainable, bug-prone code.

webbiedave
  • 48,414
  • 8
  • 88
  • 101
1

The variable $blah must contain a valid variable name.

This will tell you about variables: http://www.php.net/manual/en/language.variables.basics.php

zsalzbank
  • 9,685
  • 1
  • 26
  • 39
0

Not really an answer, but...

<?php 
function I_love_you()
{
    return "haha";
}

$haha = "HoHoHo";
$tom = "I_love_you";
$blah = "tom";

echo ${$$blah()};
?>
DampeS8N
  • 3,621
  • 17
  • 20