Confused about ColdFusion syntax (quotes and pound signs) -


i'm confused 2 different styles of syntax , want know 1 considered programming practise coldfusion.

in first example, returnvariable not using double quotes. nor cfset variable:

<cfinvoke component="#userobj#" method="mymethod"         username="#myusername#"         returnvariable= returnvar><!--- no double quotes --->  <!--- no double quotes & no pound signs ---> <cfset session.userright = returnvar> 

in second example, code is using double quotes returnvariable , cfset. first 1 set returnvar while other 1 using double quotes , pound signs "#retunsvar#"

<cfinvoke component="#userobj#" method="mymethod"         username="#myusername#"         returnvariable= "returnvar"><!--- using double quotes  --->  <!--- using double quotes & pound signs ---> <cfset session.userright = "#returnvar#"> 

it looks can use both styles , either work?

if you're looking programming practice should start not using cfinvoke

if you're on coldfusion 9 or higher can use follow syntax.

<cfset userobj = new userobj()> <cfset returnvar = userobj.mymethod(myusername)> <cfset session.userright = returnvar> 

or can simplify more eliminating setting of variable

<cfset userobj = new userobj()> <cfset session.userright = userobj.mymethod(myusername)> 

there no need use " or # when setting variable. recommend not using type of variable named retvar or returnvar or somethingthatdoesn'texplainwhatitis


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -