Hello! I'm having trouble with a class that extends another, and I don't think I understand the 'extends' concept properly. I've had my nose in various manuals, but I haven't had any luck figuring it out. Here's a simplified version of my code:
class Position {
private $latitude = 0;
private $longitude = 0;
public function getLatitude(){
return $this->latitude;
}
public function getLongitude(){
return $this->longitude;
}
}
class Coordinates extends Position {
function __construct($nlat, $nlong){
$this->latitude = $nlat;
$this->longitude = $nlong;
}
}
$lat = -123;
$long = 44;
$coordFirst = new Coordinates($lat,$long);
print($coordFirst->getLatitude());
I expect -123 to be printed, but I always get 0 instead. Could someone let me in on what I'm missing here?
Thanks a bunch!