samedi 21 février 2015

Could not be converted to string. - GeoIP

The error I'm getting is:


Catchable fatal error: Object of class GeoIp2\Database\Reader could not be converted to string in /home/choicesa/public_html/autoinsurechoice/rcom/zr/autozip.php on line 15


The code:



<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once 'vendor/autoload.php';
//require '../geoip2.phar';

use GeoIp2\Database\Reader;

// This creates the Reader object, which should be reused across
// lookups.
$reader = new Reader('GeoLite2-City.mmdb');

echo "Reader obj: $reader<br>";

// Replace "city" with the appropriate method for your database, e.g.,
// "country".
$record = $reader->postal('128.101.101.101');

print($record->country->isoCode . "\n"); // 'US'
print($record->country->name . "\n"); // 'United States'
print($record->country->names['zh-CN'] . "\n"); // '美国'

print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota'
print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN'

print($record->city->name . "\n"); // 'Minneapolis'

print($record->postal->code . "\n"); // '55455'

print($record->location->latitude . "\n"); // 44.9733
print($record->location->longitude . "\n"); // -93.2323

//header('Refresh: 3;url=http://ift.tt/1B1jv0y');
?>

Aucun commentaire:

Enregistrer un commentaire