Well, not always, but sometimes. I always thing about ColdFusion as a top-down processing system. And, it is. But what I forget is that the page gets compiled before it gets run. Because of that (or at least this is what I am assuming), ColdFusion methods that are declared within a given template can come AFTER the code that references them so long as that reference is also in the same template.
In other words, this runs perfectly well:
<!--- Get some reassurance. ---> #GetReassurance( "Am I good enough?" )# <cffunction name="GetReassurance" access="public" returntype="string" output="false" hint="Reassures you that you are good enough."> <cfreturn "Look dude, you are the man! Don't fight it." /> </cffunction>
Logically, I would expect that page to fail as the line that calls GetReassurance() is referring to a user defined method that has not yet been defined. But, since this method gets compiled with the page, I guess same-template references do not require a particular order.
If the ColdFusion user defined method was put into a CFInclude, this would fail. This only works if the method is defined IN THE SAME PAGE.
Want to use code from this post? Check out the license.