1

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?

James Newell
  • 652
  • 8
  • 12

3 Answers3

4

Small typo:

once you compare 433 with $port and not 443!

$port == 433

vs

443 == $port
Sirko
  • 72,589
  • 19
  • 149
  • 183
3

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! ;)

Matt Humphrey
  • 1,554
  • 1
  • 12
  • 30
0

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

Prashant
  • 152
  • 1
  • 16