All Questions

171
votes
12answers
74595 views

How do I create a variable number of variables?

How do I accomplish variable variables in Python? Here is an elaborative manual entry, for instance: Variable variables I have heard this is a bad idea in general though, and it is a security hole ...
70
votes
8answers
46618 views

"Variable" variables in Javascript?

I know it's possible in PHP to have "variable" variables. For example $x = "variable"; $$x = "hello, world!"; echo $variable; // displays "hello, world!" Is this possible in javascript? How would...
9
votes
6answers
1132 views

What's an actual use of variable variables?

Variable variables seem pretty cool, but I can't think of a scenario where one would actually use them in a production environment. What would such a scenario be? How were they used?
30
votes
5answers
23919 views

How do I import variable packages in Python like using variable variables ($$) in PHP?

I want to import some package depending on which value the user chooses. The default is file1.py: from files import file1 If user chooses file2, it should be : from files import file2 In PHP, I...
3
votes
4answers
3771 views

Variable Variables Pointing to Arrays or Nested Objects

Is it possible to create a variable variable pointing to an array or to nested objects? The php docs specifically say you cannot point to SuperGlobals but its unclear (to me at least) if this applies ...
4
votes
9answers
6083 views

Variable variable class extensions in PHP--is it possible?

Is something like the following possible in PHP? $blah = 'foo1'; class foo2 extends $blah { //... } class foo1 { //... } This gives an error. I want to dynamically set $blah so I can ext...
12
votes
3answers
6339 views

what is "$$" in PHP

I saw this code if (is_null($$textVarName)) { $$textVarName = $_defaultTexts[$type]; } what is code "$$" ?
5
votes
1answers
220 views

variable-variables in PHP

I know you can do: $hash('foo') and $$foo and also $bar[$foo], what are each of these things called?
3
votes
3answers
5170 views

Construct a PHP variable name based on other variable values and static text

I want to tell my function which variable to call based on the day of the week. The day of the week is stored in $s_day, and the variables I want to call changes based on which day it is. e.g. I've ...
9
votes
1answers
33521 views

How do I dynamically create the variable name in a PHP loop?

Ok so i have this php foreach loop <?php foreach ($step_count->rows as $step) { ?> and $step will be the step numbers 1, 2, 3, 4, 5 up to the total steps within the loop i a need to set ...

Previous Next