ColdFusion isDefined

前端 未结 4 595
名媛妹妹
名媛妹妹 2021-01-05 19:01

I am trying to check to see if data exist in my form If data does not exist I want to assign it to O. How can I do this.



        
4条回答
  •  情话喂你
    2021-01-05 19:44

    Generally the best practice is considered to be to avoid isDefined. This is because isDefined will search all scopes until it finds a matching variable. So it's more efficient to use structKeyExists, eg:

    
       
    
    

    Also, another way to achieve this is to use cfparam, and specify 0 as the default:

    
    

提交回复
热议问题