note 112120 added to function.geoip-record-by-name

From: Date: Tue, 07 May 2013 03:42:54 +0000
Subject: note 112120 added to function.geoip-record-by-name
Groups: php.notes 
Request: Send a blank email to php-notes+get-194723@lists.php.net to get a copy of this message
I know this may be obvious to some but I thought I would post it anyway to help others. The GEOIP section of the PHP site is a bit limited in useful tips/documentation other than the initial functions and examples. If you are trying to get information about the specific user visiting your site, you should use their IP address via the remote address in the GEOIP function. In addition here are some useful bits of code to pull certain information from the function. <?php # Collect a specific users GEOIP info $info = geoip_record_by_name($_SERVER['REMOTE_ADDR']); print_r ($info); # To get the info from one specific field $country = $info['country_name']; echo $country; # To combine information from the array into a string $info = implode("/", $info); echo $info; ?> Note on field in this array is NOT included, the connection speed of the user. To find the connection speed/connection type the visitor has, you can use the geoip_id_by_name() function. Lastly it is a good idea on whatever platform you are using GEOIP on to make sure it's data is up-to-date. On most Linux/UNIX systems with terminal you can use "pear update-channels" and "pecl update-channels" commands to keep your libraries updated. This is a good idea because GEOIP databases and country/location codes often change over time. ---- Server IP: 69.147.83.199 Probable Submitter: 24.131.27.37 ---- Manual Page -- http://php.net/manual/en/function.geoip-record-by-name.php Edit -- https://master.php.net/note/edit/112120 Del: integrated -- https://master.php.net/note/delete/112120/integrated Del: useless -- https://master.php.net/note/delete/112120/useless Del: bad code -- https://master.php.net/note/delete/112120/bad+code Del: spam -- https://master.php.net/note/delete/112120/spam Del: non-english -- https://master.php.net/note/delete/112120/non-english Del: in docs -- https://master.php.net/note/delete/112120/in+docs Del: other reasons-- https://master.php.net/note/delete/112120 Reject -- https://master.php.net/note/reject/112120 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194723) next »