PHP Community Marketing Expert Question:

Download Job Interview Questions and Answers PDF

Explain why would we use === instead of ==?

PHP Community Marketing Expert Interview Question
PHP Community Marketing Expert Interview Question

Answer:

If you would want to check for a certain type, like an integer or boolean, the === will do that exactly like one would expect from a strongly typed language, while == would convert the data temporarily and try to match both operand’s types. The identity operator (===) also performs better as a result of not having to deal with type conversion. Especially when checking variables for true/false you want to avoid using == as this would also take into account 0/1 or other similar representation.

Download PHP Community Marketing Expert Interview Questions And Answers PDF

Previous QuestionNext Question
Suppose we receive a form submitted by a post to subscribe to a newsletter. This form has only one field, an input text field named email. How would we validate whether the field is empty? Print a message "The email cannot be empty" in this case?Tell me what is htaccess? Why do we use this and where?