Jump to content

Kepesk

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by Kepesk

  1. Wow thanks, that solved it perfectly!
  2. 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!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.