If you want PHP to do it you'll need the client to make some sort of request to the server. That's because the server is where PHP is running. If you want do any processing of any sort on the client ... that's what Javascript is for.
What, precisely, are you trying to do? Change an <img> tag's src attribute according to some condition, I presume.