Variables / Variable  

Related Pages

Type casting
Array to object
New object

0.0% 100%
0 pages 298 questions
1) Fill the blank <?php $name = '123'; $$name = '456'; echo _______; // output 456

2) What will be the error (if any) in case of the following code <?php function foo() {} $function = "foo"; $function();

3) What will be the output? <?php $name = 'foo'; $$name = 'bar'; echo $foo;

<?php $name = 'foo'; $$name = 'bar'; echo $foo; // Displays 'bar' It is possible to create variables whose names do not follow the variables constraints. <?php $name = '123'; $$name = '456'; echo ${'123'}; // output 456 Variable variables are a very powerful tool, and should be used with extreme care. Their improper use can lead to some significant security issues. A technique similar to variable variables can also be used to hold function names inside a variable: <?php function myFunc() { echo 'myFunc!'; } $f = 'myFunc'; $f(); // output myFunc!