Php equal sign (=) and full equal sign (=) _ PHP Tutorial

Source: Internet
Author: User
Php equal sign () and full equal sign (). Php equal sign () and full () require_oncePerson.php; header (content-type: texthtml; charsetutf-8); $ person001newPerson (wuxifu, 110); $ person002newPerson (wuxifu, 110 ); $ php equal sign (=) and full equal sign (=)


Require_once "Person. php ';
Header ("content-type: text/html; charset = utf-8 ");
$ Person001 = new Person ("wuxifu", 110 );
$ Person002 = new Person ("wuxifu", 110 );
$ Person003 = $ person001;
// Equality (=) indicates that the data type must be the same first. if the data type is different, the value is false.
// (1) if it is an object after being of the same data type (true if it is the same object)

Echo"
If person001 and person002 are not the same object, they are not all *************
";
If ($ person001 ===$ person002)
{
Echo "person001 === person002 is the same object ";
} Else
{
Echo "person001! = Person002 is not the same object ";

}
Echo"
When person001 and person003 are the same object, they are all **************
";
If ($ person001 ===$ person003)
{
Echo "person001 === person003 is the same object ";
} Else
{
Echo "person001! = Person003 is not the same object ";

}
// (2) after the same data type, if it is an array (if the content is the same, true or false)
$ Array = array (110,120,130 );
$ Array2 = array (110,120,130 );
$ Array3 = $ array;
Echo"

Array and array2 are not the same array, but the content is the same. they are all *************
";
If ($ array = $ array2)
{
Echo "array = array2 ";
} Else
{
Echo "array! = Array2 ";
}
Echo"
Array and array3 are not the same array, but the content is the same. they are all ************************
";
If ($ array ===$ array3)
{
Echo "array = array3 ";
} Else
{
Echo "array! = Array3 ";
}
Echo"
Array and array3 are not the same array, and the content is different. they are not complete ***********************
";
$ Array3 [0] = 0;
If ($ array ===$ array3)
{
Echo "array = array3 ";
} Else
{
Echo "array! = Array3 ";
}
Echo"
";
// (3) after the same data type, if it is four scalar types (boolean, integer, float, string), if the value is the same, true or false
Echo"
If it is of the same data type (boolean, integer, float, string) and the value is the same, true or false
";

$ Nums = 110;
USD nums2 = 120;
$ Nums3 = 110;
If ($ nums ===$ nums2)
{
Echo "nums = the same value as nums2 ";
} Else
{
Echo "nums! = Different nums2 values ";

}
Echo"
";
If ($ nums ===$ nums3)
{
Echo "nums = the same value as nums3 ";
} Else
{
Echo "nums! = Different nums3 values ";

}
// (4) false if the data type is not the same
Echo"

********************************
";
If ($ nums = true)
{
Echo "nums = true ";
} Else
{
Echo "nums! = True ";

}
Echo"
";
If ($ person001 === true)
{
Echo "person001 = true ";
} Else
{
Echo "person001! = True ";

}

?>




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


Require_once "Person. php ';
Header ("content-type: text/html; charset = utf-8 ");
$ Person001 = new Person ("wuxifu", 110 );
$ Person002 = new Person ("wuxifu", 110 );
$ Person003 = $ person001;
// Wait (=) to judge whether the data type is the same first. if the equal sign has one side of the boolean type, the other side is converted to the boolean type, otherwise, the data type on the right of the equal sign is forcibly converted to the data type on the left.
// (1) if it is an object after the same data type (true if the content of the two objects is the same)
Echo"
If person001 and person002 are not the same object, but the content is the same *************
";

If ($ person001 = $ person002)
{
Echo "person001 = same content as person002 ";
} Else
{
Echo "person001! = Different person002 content ";

}
Echo"
When person001 and person003 are the same object (the same content), and so on **************
";

If ($ person001 = $ person003)
{
Echo "person001 = person003 is the same object ";
} Else
{
Echo "person001! = Person003 is not the same object ";

}
// (2) after the same data type, if it is an array (if the content is the same, true or false)
$ Array = array (110,120,130 );
$ Array2 = array (110,120,130 );
$ Array3 = $ array;
Echo"

Array and array2 are not the same array, but the content is the same *************
";

If ($ array = $ array2)
{
Echo "array = array2 ";
} Else
{
Echo "array! = Array2 ";
}
Echo"
Array and array3 are not the same array, but the content is the same ************************
";

If ($ array = $ array3)
{
Echo "array = array3 ";
} Else
{
Echo "array! = Array3 ";
}
Echo"
Array and array3 are not the same array and their content is different ***********************
";

$ Array3 [0] = 0;
If ($ array = $ array3)
{
Echo "array = array3 ";
} Else
{
Echo "array! = Array3 ";
}
Echo"
";
// (3) after the same data type, if it is four scalar types (boolean, integer, float, string), if the value is the same, true or false
Echo"
If it is of the same data type (boolean, integer, float, string) and the value is the same, true or false
";

$ Nums = 110;
USD nums2 = 120;
$ Nums3 = 110;
If ($ nums = $ nums2)
{
Echo "nums = the same value as nums2 ";
} Else
{
Echo "nums! = Different nums2 values ";

}
Echo"
";
If ($ nums = $ nums3)
{
Echo "nums = the same value as nums3 ";
} Else
{
Echo "nums! = Nums3 values are different ";

}
// (4) not the same data type. if one side of the equal sign has a boolean value, the other side is converted to the boolean type, otherwise, the data type on the right of the equal sign is converted to the data type on the left of the equal sign.
Echo"

Not the same data type. if one side of the equal sign has a value of the boolean type, the other side is converted to the boolean type, otherwise, the data type on the right of the equal sign is changed ***************************** ***
";

If ($ nums = true)
{
Echo "nums = true ";
} Else
{
Echo "nums! = True ";

}
Echo"
";
If ($ person001 = true)
{
Echo "person001 = true ";
} Else
{
Echo "person001! = True ";

}
Echo"
";
If (true = $ nums)
{
Echo "true = nums ";
} Else
{
Echo "true! = Nums ";

}
Echo"
";
If (true = $ person001)
{
Echo "true = person001 ";
} Else
{
Echo "true! = Person001 ";

}
Echo"
";
If ($ array = $ person001)
{
Echo "array = person001 ";
} Else
{
Echo "array! = Person001 ";

}
Echo"
";
If ($ array = true)
{
Echo "array = true ";
} Else
{
Echo "array! = True ";

}

?>

Equals (=) and equals (=) require_once "Person. php '; header ("content-type: text/html; charset = utf-8"); $ person001 = new Person ("wuxifu", 110 ); $ person002 = new Person ("wuxifu", 110); $...

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.