Hi I’m using CakePHP and I’m wondering do you guys puts isset() or !empty() around all of your variables in the views? Or should I depend on the data validation? What would be the suggested solution?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you should know the differences between
issetandemptyand use the one that fulfills your needs.emptywill returnFALSEif the variable has a non-empty and non-zero value.The following values are considered to be empty:
""(an empty string)0(0 as an integer)"0"(0 as a string)NULLFALSEarray()(an empty array)var $var;(a variable declared, but without a value in a class)On the other hand
issetwill returnFALSEif the variable does not exist or has been unset withunset(), or the variable has been set toNULL.