PHP Variable Variables
In PHP sometimes you may want to have variable variables or dynamic function calls for whatever reason. PHP allows you to programmatically construct variable and function names. Here is an example of a variable function call from within a class. Thsi would call the function named myFunc:
$this->{$variable}();
Sometimes you may want to create variable names on the fly, let's say in a loop where you are updating many records from a form post. This code would make a variable named commonCust and assign it a value of 1:
${'common'.$custom} = '1';
You’re currently reading “ PHP Variable Variables ,” an entry on BRADINO
- Published:
- 11.20.07 / 1pm
- Category:
- PHP












