PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Dwayne Rothe   IP2Country PHP   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: IP2Country PHP
Get information of the country of an IP address
Author: By
Last change:
Date: 12 years ago
Size: 1,618 bytes


Class file image Download
// example of basic use

// set directory path to where the ip2countryphp.sql.php file is
// this MUST be a relative path and MUST include the end slash /

// set width of flag, height is proportional to width.
$flag_width = "30";

// include the class file

Below is a heredoc example of how you might display the users info,
of course you can include only the variables you want to, or you might
want to store the ip address, 2 letter country code(for flag image) and
country name in a database for using on a specific page.

print <<<TEST
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<title>ip2country PHP - (MySQL)</title>
<body style="font:normal 9pt tahoma,arial,verdana">
<table style="margin-top:20px;border:#CCCCCC 1px solid" width="280" cellspacing="2" cellpadding="3" border="0" align="center">
  <tr><td bgcolor="#CCCCCC" colspan="2">&nbsp;<font color="white">ip2country PHP - (MySQL)</font></td></tr>
  <tr><td width="120" height="26">IP Address:</td><td>
  <tr><td>Country name:</td><td>
  <tr><td>2 letter code:</td><td>
  <tr><td>3 letter code:</td><td>
  <tr><td>Country flag:</td><td><img src="
$flag_img" width="$flag_width" border="0"></td></tr>
  <tr><td bgcolor="#CCCCCC" colspan="2"><font color="white" size="1"></font></td></tr>