Created
August 14, 2015 09:49
-
-
Save james-jlo-long/1cd15de92b0ed92d1440 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo { | |
public function __construct($name) { | |
$this->name = $name; | |
} | |
public function getName() { | |
return $this->name; | |
} | |
} | |
class Bar extends Foo { | |
public function __construct($name, $job) { | |
parent::__construct($name); | |
$this->job = $job; | |
} | |
public function getUpperName() { | |
return strtoupper($this->name); | |
} | |
} | |
$foo = new Foo('JLo'); | |
$foo->name; // "JLo" | |
$foo->job; // null | |
$foo->getUpperName(); // Exception | |
$bar = new Bar('JLo', 'WebDev'); | |
$bar->name; // "JLo" | |
$bar->job; // "WebDev" | |
$bar->getUpperName(); // "JLO" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment