Search code examples
coldfusionconstantscoldfusion-9

Are constants supported in ColdFusion?


I am using ColdFusion 9 and have checked the documentation but it is ambiguous.

https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/elements-of-cfml/constants.html

(I have PHP background and looking for something similar to PHP constants)

Thanks


Solution

  • No, ColdFusion does not have constants. I think in most cases developers just set a variable, using some naming convention such as the variable name in ALL_CAPITALS, and then never change it's value. This is not really a constant as in other languages and you really have to be careful that the value is not changed (because it is not a true constant). I have done this before and typically set these "constants" in the application scope so they are readily available.

    There was an enhancement request opened a while back. However, it looks like it has been closed and deferred.

    Adam Cameron blogged about this very thing last year and references the same enhancement request.