PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Tassadduq Hussain  >  PHP Distance Calculation using Latitude and Longitude  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Distance Calculation using Latitude and Longitude
Calculate the distance between two world locations
Author: By
Last change:
Date: 2 years ago
Size: 624 bytes


Class file image Download
//include the class
//initiate class
$dc = new DistanceCalculator();

//latitude and logtitude of point 1
$dc->lat1 = 33.6437323;
$dc->long1 = 72.9585014;

//latitude and logtitude of point 2
$dc->lat2 = 33.6655587;
$dc->long2 = 73.0022321;

//define the unit of distance you want to get get data, default is 'miles'
$dc->type = 'km';

//choose if you want to display the selected unit type with the distance value, default is 'true'
$dc->show_type = false;

//calculate and get the distance
$distance = $dc->getDistance();

//show the calculated distance
echo $distance;

For more information send a message to info at phpclasses dot org.