Reputation: 653
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?
Upvotes: 1
Views: 99
Reputation: 1554
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! ;)
Upvotes: 3
Reputation: 152
You are setting 443 in $port and comparing with 433. This will always return false.
Upvotes: 0
Reputation: 74086
Small typo:
once you compare 433 with $port
and not 443!
$port == 433
vs
443 == $port
Upvotes: 4