=== & !==
Posted: Wed May 11, 2005 2:37 am
What are === & !== used for?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$int = 123;
$string = '123';
if ($int === $string) {
echo "something's wrong";
} else {
echo "nothing wrong";
}
if ($int == $string) {
echo "nothing wrong";
} else {
echo "something's wrong";
}Code: Select all
//Comparisons
== Is the same as
!= Not the same as
=== Identical to
!== Not identical to
//Bitwise
&& AND
|| ORCode: Select all
function dostuff()
{
// returns false if stuff failed
// otherwise returns the number of processed items
}Code: Select all
if (!dostuff()) { // operation was not a success }Code: Select all
if (dostuff() !== false) { // operation was succes }