I'm using the ColdBox framework in ColdFusion. I would like to know how to use static variables in a function. Can anyone explain how, or suggest an alternative to the "static" concept.
Asked
Active
Viewed 1,587 times
3
-
1'static variable' is a contradiction in terms... do you mean a constant? – duncan Mar 02 '13 at 08:42
-
2There's no static. There's Application scope though, just sticks whatever static you want there and use it from there throughout – Henry Mar 02 '13 at 09:22
-
1Coldfusion does not use static variables. What are you trying to accomplish with this variable? – Dan Bracuk Mar 02 '13 at 11:45
-
1In the context of ColdFusion, your question doesn't make much sense. Can you include some code (or pseudo-code) of what you're trying to accomplish? – ale Mar 02 '13 at 17:36
-
I suppose you could make a CFC and disable the setter? – BKK Mar 02 '13 at 22:21
-
Similar Question and Answer here: http://stackoverflow.com/questions/7288302/what-is-the-equivalent-of-static-methods-in-coldfusion – James A Mohler Mar 04 '13 at 16:55
-
Similar Question and Answer here: http://stackoverflow.com/questions/7288302/what-is-the-equivalent-of-static-methods-in-coldfusion – James A Mohler Mar 04 '13 at 16:56
-
Similar Question and Answer here: http://stackoverflow.com/questions/7288302/what-is-the-equivalent-of-static-methods-in-coldfusion – James A Mohler Mar 04 '13 at 16:57
1 Answers
4
Using a component's metadata we can mimic static variable behavior:

Sebastian Zartner
- 18,808
- 10
- 90
- 132

coldfusiondevshop
- 683
- 4
- 6