php equals (= =) and congruent (= = =) _php Tutorial

Source: Internet
Author: User
Tags scalar

php equals (= =) and congruent (= = =)



Require_once "person.php";
Header ("Content-type:text/html;charset=utf-8");
$person 001=new person ("Wuxifu", 110);
$person 002=new person ("Wuxifu", 110);
$person 003= $person 001;
//congruent (= = =) To determine the first data type to be the same, the data type is False
(1) If the object is the same data type (true if the same object is false)

echo "
PERSON001 and person002 are not the same object in the case, not congruent *************
";
if ($person 001=== $person 002)
{
echo "person001===person002 is the same object";
}else
{
echo "person001!==person002 is not the same object";

}
echo "
Person001 and person003 are identical objects in the case of congruent **************
";
if ($person 001=== $person 003)
{
echo "person001===person003 is the same object";
}else
{
echo "person001!==person003 is not the same object";

}
//(2) is the same data type, if it is an array (true if the content is false)
$array =array (110,120,130);
$array 2=array (110,120,130);
$array 3= $array;
echo "

Array is not the same array as array2, but the same as content, congruent *************
";
if ($array = = = $array 2)
{
echo "Array===array2";
}else
{
echo "Array!==array2";
}
echo "
Array is not the same array as ARRAY3, but the same as content, congruent ************************
";
if ($array = = = $array 3)
{
echo "Array===array3";
}else
{
echo "Array!==array3";
}
echo "
Array and array3 are not the same array, the content is not the same, not congruent ***********************
";
$array 3[0]=0;
if ($array = = = $array 3)
{
echo "Array===array3";
}else
{
echo "Array!==array3";
}
echo "
";
//(3) is the same data type, if it is four scalar types (boolean,integer,float,string), the same value is true no is false
echo "
Is the same data type, if it is four scalar types (boolean,integer,float,string), the same value is true no is false
";

$nums = 110;
$nums 2=120;
$nums 3=110;
if ($nums = = = $nums 2)
{
echo "Nums===nums2 value";
}else
{
echo "Nums!==nums2 value is not the same";

}
echo "
";
if ($nums = = = $nums 3)
{
echo "Nums===nums3 value";
}else
{
echo "Nums!==nums3 value is not the same";

}
//(4) is not the same data type, or false
echo "

Not the same type is false not congruent ********************************
";
if ($nums ===true)
{
echo "Nums===true";
}else
{
echo "Nums!==true";

}
echo "
";
if ($person 001===true)
{
echo "Person001===true";
}else
{
echo "Person001!==true";

}

?>




*************************************************************


Require_once "person.php";
Header ("Content-type:text/html;charset=utf-8");
$person 001=new person ("Wuxifu", 110);
$person 002=new person ("Wuxifu", 110);
$person 003= $person 001;
//wait (= =) to determine the data type first, not the same, if one side of the equal sign is a Boolean type, the other side is converted to a Boolean type, otherwise the right side of the equal sign will be cast to the left data type
(1) is the same data type, if the object (as long as the contents of the two objects is true no is false)
echo "
PERSON001 is not the same object as person002, but the content is equal to *************
";

if ($person 001== $person 002)
{
echo "person001==person002 content";
}else
{
echo "person001!=person002 content is not the same";

}
echo "
PERSON001 is the same object as person003 (content), etc. **************
";

if ($person 001== $person 003)
{
echo "person001==person003 is the same object";
}else
{
echo "person001!=person003 is not the same object";

}
//(2) is the same data type, if it is an array (true if the content is false)
$array =array (110,120,130);
$array 2=array (110,120,130);
$array 3= $array;
echo "

Array is not the same array as array2, but the contents are the same, etc. *************
";

if ($array = = $array 2)
{
echo "Array==array2";
}else
{
echo "Array!=array2";
}
echo "
Array is not the same array as array3, but the contents are the same, etc. ************************
";

if ($array = = $array 3)
{
echo "Array==array3";
}else
{
echo "Array!=array3";
}
echo "
Array and array3 are not the same array, the content is not the same, unequal ***********************
";

$array 3[0]=0;
if ($array = = $array 3)
{
echo "Array===array3";
}else
{
echo "Array!==array3";
}
echo "
";
//(3) is the same data type, if it is four scalar types (boolean,integer,float,string), the same value is true no is false
echo "
Is the same data type, if it is four scalar types (boolean,integer,float,string), the same value is true no is false
";

$nums = 110;
$nums 2=120;
$nums 3=110;
if ($nums = = $nums 2)
{
echo "Nums==nums2 value";
}else
{
echo "NUMS!==NUMS2 value is not the same";

}
echo "
";
if ($nums = = $nums 3)
{
echo "Nums==nums3 value";
}else
{
echo "Nums!=nums3 value is not the same";

}
(4) is not the same data type, if one side of the equals sign has a Boolean value, the other side is converted to a Boolean type, otherwise the right side of the equal sign will be turned to the data type to the left of the equals sign
echo "

is not the same data type, if there is a Boolean value on one side of the equal sign, the other side is converted to a Boolean type, otherwise the right side of the equal sign is turned to the data type on the left of the equals sign ********************************
";

if ($nums ==true)
{
echo "Nums==true";
}else
{
echo "Nums!=true";

}
echo "
";
if ($person 001==true)
{
echo "Person001==true";
}else
{
echo "Person001!=true";

}
echo "
";
if (true== $nums)
{
echo "True==nums";
}else
{
echo "True!=nums";

}
echo "
";
if (true== $person 001)
{
echo "true==person001";
}else
{
echo "true!=person001";

}
echo "
";
if ($array = = $person 001)
{
echo "array==person001";
}else
{
echo "array!=person001";

}
echo "
";
if ($array ==true)
{
echo "Array==true";
}else
{
echo "Array!=true";

}

?>

http://www.bkjia.com/PHPjc/847855.html www.bkjia.com true http://www.bkjia.com/PHPjc/847855.html techarticle php equals (= =) and congruent (= = =) require_once "person.php"; Header ("Content-type:text/html;charset=utf-8"); $person 001=new person ("Wuxifu", 110); $person 002=new person ("Wuxifu", 110); $...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.