MemoryRefresh!

Variables / Variable   Variable



Questions Answers 0%

Pages   0 from 91
Questions   0 from 142

Reset



<?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!

Related Pages

Definition
Variable
Check
Type casting
Array to object
New object


0% 100%
 
 
0 pages 91 pages
1) What will be the output? <?php $name = 'foo'; $$name = 'bar'; echo $foo;





2) Fill the blank <?php $name = '123'; $$name = '456'; echo _______; // output 456





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









<?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!

References









Programming

Php
   
Regex
   
MySQL
   
Css
   
jQuery
   
Git
   


References