PHP congruent ()

Source: Internet
Author: User
Tags scalar
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";

}
?>
  • 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.