PHP平等 - 我哪里错了?

This is driving me nuts. Two integers should be equal.

<?php

function getPort() {
    return 443;
}

$port = getPort(); 
var_dump(433, $port, $port == 433, 443 == $port, 433 == 433);

?>

Result in both PHP 5.2 and 5.4:

int(433)
int(443)
bool(false)
bool(true)
bool(true)

In the previous code why does $port not equal 443 but 443 does equals $port? I must be doing something stupid surely?

Your doing $port == 433 in the first parameter and 443 in the second, and therefore it is correct.

So, to answer your question, yes; you are doing something stupid! ;)

Small typo:

once you compare 433 with $port and not 443!

$port == 433

vs

443 == $port

You are setting 443 in $port and comparing with 433. This will always return false.