Search code examples
phpvariablesvariable-variables

How to access a variable variable with a name containing spaces?


How does PHP handle something like this:

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

What would I access my dynamically declared variable?


Solution

  • echo ${'Testing a variable'};

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