This is how to do it in Safari:
1. Quit Safari
2. Open /Applications/Terminal.
3. Type "defaults write com.apple.Safari IncludeDebugMenu 1", then return
4. Open Safari
5. Go to Debug menu->User Agent (third from the bottom), and choose the browser of choice.
Note: You should avoid using this when possible. If everyone does this, then the statistics that web admins get will show that IE is used more than it really is, and hence they may support other browsers less.