A lot of networks are secured. Basically that means you have to know a key/password to use them. With my MacBook Pro I have to enter the key/password the first time I use a new network. The next time I want to use that network the MBP remembers the key/password for me. I am sure that is how the iPhone will work as well.
Steve's comment about wifi being automatic was in reference to switching from EDGE to wifi and back. If there is a wifi network available, the iPhone will use it and if not it will use EDGE.
The post above is 100% correct.
I would like to ad the following details, since I use WiFi everywhere, everyday. I travel for businesss and a laptop is my main computer.
It could be said that there are "three" categories of WiFi Access:
1) Unsecured access in a "Hot-Spot" that is free.
2) Unsecured access in a hot-spot that you pay for.
Think: Starbucks which uses T-Mobile as their service provider. I use T-Mobile when meeting clients at Starbucks weekly. They also serve many hotels, bookstores, airports etc.
3) Secured access in a hot-spot that requires a password to gain access.
These are typically the kind that the government & corporations use.
In each of the scenarios above it's customary to see a pop up box appear that shows you the network or networks (as there are often more than just one in range) you have available to you. At this point you choose which wireless network you wish to connect to and proceed accordingly.
In my particular case all the networks I use with the exception of Starbucks are Secured access points, requiring a password or authentication code.
I have a secured network at my home, office, satellite office, etc.
Hope this helps answer your questions.
Cheers...