Following code:
<?php
$str = "19.09.02";
if(substr($str, -3, 2) == ".0")
{
// Doing something
}
$str2 = "19.09.2002";
if(substr($str2, -3, 2) == ".0")
{
// Doing something
}
?>
Why does the second statement apply (without regexp)? and how can I solve, that it just apply the first expression?
Thank you
I think you should use the identity (===) operator to fix this 🙂
One of the main differences of === vs == is that === doesn’t cast at all, it is a very strict comparison.