Jnr PHP/Codeigniter Developer Question:

Download Job Interview Questions and Answers PDF

Tell me why would you use === instead of ==?

Jnr PHP/Codeigniter Developer Interview Question
Jnr PHP/Codeigniter Developer 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, one should avoid using == as this would also take into account 0/1 or other similar representation.

Download Jnr PHP/Codeigniter Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Do you know in a PHP class, what are the three visibility keywords of a property or method?Tell me the value of the variable input is a string 1,2,3,4,5,6,7.
How would you get the sum of the integers contained inside input?