PHP Classes

File: demo.php

Recommend this page to a friend!
  Classes of Tiago André   Localization class   demo.php   Download  
File: demo.php
Role: Example script
Content type: text/plain
Description: demo file
Class: Localization class
Detect user location using HTML 5 API or GeoIP API
Author: By
Last change:
Date: 12 years ago
Size: 922 bytes
 

Contents

Class file image Download
<?php
include('geoip.class.php');
$geoip=new geoIP();
$js_code_to_location = $geoip->location_html5("$('#city').text(place);");
$country=$geoip->get_location();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
    <title>untitled</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="generator" content="Geany 0.21" />
    <script type='text/javascript' src='http://maps.googleapis.com/maps/api/js?sensor=false'></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
    <script>
    <?php echo $js_code_to_location; ?>
</script>
</head>

<body>
    <b>City via IP API</b>
    <pre>
    <?php print_r($country); ?>
</pre>
    <b>city via HTML5 geolocalisation</b>
    <div id='city'></div>
</body>

</html>