Distance calculation from coordinates

This script calculates the distance between two locations, the latitude and 
longitude of which are known. The coordinates are given in decimal degrees.
South latitudes and west longitudes are negative.

The calculation formulae is so called great-circle distance calculation, which 
assumes a spherical earth. The accuracy of the calculation is not as perfect 
as in the more complicated Vincenty's formulae, which assumes the earth to be an 
oblate spheroid. The error is however under 0.3% in most cases.
Location 1:   Latitude     Longitude
Location 2:   Latitude     Longitude

Warning: Undefined variable $herja in /home/r122164/public_html/tools/distance.php on line 114

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/r122164/public_html/tools/distance.php:114 Stack trace: #0 {main} thrown in /home/r122164/public_html/tools/distance.php on line 114