You really cannot do this accurately. You should set a default language to start with so if you cannot locate the language the user is using than you can fall back to that. The only way that I am aware of to do this is by finding the userAgent string of the browser majority of the time you will find the language in there.
$userAgent = $_SERVER['HTTP_USER_AGENT'];
From there its a matter of finding the language which maybe quite difficuilt. Also some users may give false or choose not to send the userAgent string to the server.