This file I am using but I got this warning.
The script is running okay. But I want to get rid of the message.
The line : $myObj->afstand= $formattedNum . " km"; gives the warning.
I've tried to make a new class, but nothing works.
Does someone know how to get rid of the warning?
<?php
$lat1= $_POST['lat1'];
$lon1= $_POST['lon1'];
$lat2= $_POST['lat2'];
$lon2= $_POST['lon2'];
$lat3= $_POST['lat1'];
$lon3= $_POST['lon1'];
$lat4= $_POST['lat2'];
$lon4= $_POST['lon2'];
$unit = "K";
function distance($lat1, $lon1, $lat2, $lon2, $unit) {
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$unit = strtoupper($unit);
if ($unit == "K") {
return ($miles * 1.609344);
} else if ($unit == "N") {
return ($miles * 0.8684);
} else {
return $miles;
}
}
$formattedNum = number_format(distance($lat1, $lon1, $lat2, $lon2, "K"), 1);
$myObj->afstand= $formattedNum . " km";
$a = $lat3;
$a .= ",";
$a .=$lon3;
$myObj->saddr = $a;
$myObj->nwlat = $lat3;
$myObj->nwlon = $lon3;
$myObj->nwlat2 = $lat4;
$myObj->nwlon2 = $lon4;
$myJSON = json_encode($myObj);
echo $myJSON;
?>