Object in if statement returns true when compared to 1 and false to any other number [duplicate]

I noticed the following strange behavior in PHP (tested with several versions) where comparing an object == 1 returns true and the same object == 5000 returns false.

I managed to simulate this only with the following code, to test change 1 in the if to 5000 e.q.

$object = new stdClass();

$object->name = "John Doe";
$object->age = 30;
$object->email = "[email protected]";


if(1 == $object){
    echo 'true';
} else {
    echo 'false';
}
// returns true

if(500 == $object){
    echo 'true';
} else {
    echo 'false';
}
//returns false

I tried testing this also with JSON objects and classes, but doesn’t behave the same way.

PS: Asking AI will give really wrong answers.