开发者

Function to check if a variable name is valid

I have some code using the SetVariable function which takes the first parameter as a variable name created based on a variable name passed to this code.

I'm looking for a way to check the string passed to it is a valid variable name using a function rather than using a try/catch block to trap this error.

I know there's a function IsValid but this only checks if the variable is valid, not if it's a valid variable name. Does anyone have any suggestions or custo开发者_运维问答m code they've used to do this?

Thanks,

Tom


I know there's a function IsValid but this only checks if the variable is valid, not if it's a valid variable name

Actually IsValid() will do what you want if you specify "variableName" as the type.

<cfoutput>#IsValid( "variableName","1")#</cfoutput>

Will output NO, since variable names in CF cannot begin with a digit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜