PHP Classes

File: examples/kilometer.php

Recommend this page to a friend!
  Classes of Johnny Mast   Redbox PHP Distance   examples/kilometer.php   Download  
File: examples/kilometer.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Redbox PHP Distance
Compute the distance between locations or zipcodes
Author: By
Last change:
Date: 8 years ago
Size: 705 bytes
 

Contents

Class file image Download
<?php
require 'autoload.php';
use
Redbox\Distance;

/**
 * In this example we will calculate the distance between Amsterdam and Rotterdam (the Netherlands)
 * as Kilometers and display them to the user of the script.
 */
$p1 = new Distance\GeoPoint(52.364533, 4.820374); /* Amsterdam */
$p2 = new Distance\GeoPoint(51.925538, 4.471867); /* Rotterdam */

$tool = new Distance\CalculateDistance();
$distance = $tool->setSource($p1)
                 ->
setDestination($p2)
                 ->
setUseSslVerifier(false)
                 ->
getDistanceInKM();

echo
"<h2>Distance in Kilometer</h2>";
echo
'<a href="index.php">Back to index</a><br><br />';
echo
'The calculated distance is: '.$distance.' KM<br>';