Apple's latest iPhone has buggy wifi. Here's a visual walkthrough of the problem.
Note: it happens on some iPhones and not on others. I know, because I have two, with identical settings, and it does on one and not the other.
Full story here: