It's true, that usually you don't even need that information. Elements on the page should be designed in a way that dynamically takedifferent resolutions into account. I found it meaningful when designing for a mobile and desktop version of web application at the same time. The code for both is practically the same, maybe only a few PHP lines different, so I figured I will detect whether user is accessing it from mobile device or from desktop computer. Here is when the problem arose: mobile devices have hugeresolutionsnowadays; mobile doesn't equal lame anymore!
Since the screen resolution is a client attribute and PHP runs on server, it is impossible to know it. I remember that in the past one could read such information from HTTP request, but even that was just some non-standard IE header. Nowadays this header seems completely abandoned and other measures are necessary to obtain an information. We have some options left though.
What you can also do is just simply ask a user. You can offer two versions of the site by offering two slightly different URLs, for instance site.com and site.com/mobile. Plenty of internet sites use this approach. Another option is to retain the check if it is a mobile device, and then ask them if they want mobile version and store their preference in a cookie, so that you don't have to bother them again.
You can't guess what is in user's mind. Maybe he likes to squint into full-featured web page on his small screen. Maybe he would prefer less crowded and more functional mobile version in spite of his big mobile screen. Why pushing it one way or another? (What I also like is how this problem started as a technical one and ended as a lesson in the diversity of people :)