either way there are a few utils for each that will let you copy music off an ipod. now.. whether those work for an iPhone, i'm not 100% sure. i've used them in the past for an ipod and they work pretty well. they will copy from the ipod to a computer no problem. Apple doesn't support it, but plenty of people do it via 3rd party utils.
if you google 'copy music from iPhone' or 'from ipod' you'll get a list of various options. i have no specific recommendations on which are better, they all seem to work more-or-less the same.
on a mac and pc . ipod access . goggle it . works with the iPhone . gets all your music on your iPhone and transfers them to a computer your on . its 20 bucks . there is a trial version to try it out . limited though. the album artwork does not transfer . I found this to be handy when my hard drive recently died on my powerbook .
Try Senuti if you have a mac (easy to remember, its iTunes backwards). It worked prefectly with my iPod but i have yet to try it with the iPhone. And post the results of your efforts to let us know what works and what doesn't.