Difference between double and triple equal to in php
In this tutorial, i show you the difference between double and triple equal operator. double equal is used when it is required to compare values of two variables, even they are equal or not irrespective of data type. eg $v = 12 and $v1 = "12". in this case according to double equal operator both variables have same meaning. but according to triple equal operator both variable are different because their data type are different. for better understand see below code.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>difference between double and tripple equal</title>
</head>
<body>
<?php
$var1 = 12;
$var2 = 12;
// if($var1==$var2){
// echo "both variables have same values. but possibility of different data type is present.";}
if ($var1===$var2) {
echo "both variables have same values with same data type.";
}
else{
echo "both variables have different values";
}
?>
</body>
</html>
0 Comments