Question
Why setting var in CFFUNCTION causes error
As far as my knowledge goes, the BEST practise when setting
local variable inside a CFFUNCTION is to use the word "var" in
front of the variable name, for example: <CFSET var
myVariable="whatever">
I'm doing it now and all I get is an error message saying:
Error invoking CFC name_of_cfc:local variable myVariable on line 60 must be grouped at the top of the function body!
I'm using CF8 and I need to use cfswitch within the cffunction, so when I do <cfcase value="SomeValue"><cfset var myVariable="TheValue"></cfcase> etc I got that error.
When I tested with just CFSET var MyVariable="TheVariable" with no cfswitch/cfcase I still get that error
when I took out the word "var" from cfset, I have no error, I put these variables directly after my cfarguments. Does anyone know why this is happening to me?
I thought if I don't use the "var" word for my variable set within cffunction there will be possibilities when later on setting up another variables outside this function and if the name happen to be the same, will override each other and causing disaster to my application.
Please help!!
I'm doing it now and all I get is an error message saying:
Error invoking CFC name_of_cfc:local variable myVariable on line 60 must be grouped at the top of the function body!
I'm using CF8 and I need to use cfswitch within the cffunction, so when I do <cfcase value="SomeValue"><cfset var myVariable="TheValue"></cfcase> etc I got that error.
When I tested with just CFSET var MyVariable="TheVariable" with no cfswitch/cfcase I still get that error
when I took out the word "var" from cfset, I have no error, I put these variables directly after my cfarguments. Does anyone know why this is happening to me?
I thought if I don't use the "var" word for my variable set within cffunction there will be possibilities when later on setting up another variables outside this function and if the name happen to be the same, will override each other and causing disaster to my application.
Please help!!
