Why we are using triple equals here to compare ?
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
}
Why we are using triple equals here to compare ?
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
}
Many PHP functions may return mixed types, unlike many other languages. If you would compare with ==
, only values would be tested. Therefore any non-zero value would be equal to true, and also things like 123 == '123abc'
would be true.
The ===
operator requires types to be the same also, so any object is not equal to true and even 123 === '123'
doesn't equal true.