Last active
August 29, 2015 14:03
-
-
Save hrach/4c63222f61d252aa627a to your computer and use it in GitHub Desktop.
test inheritance php
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 | |
{ | |
private $name; | |
public function greet2() | |
{ | |
$this->greet('jan'); | |
echo $this->name; | |
} | |
private function greet($name) | |
{ | |
$this->name = $name; | |
} | |
} | |
class bar extends foo | |
{ | |
public function greet($name) | |
{ | |
echo "Hello" . $name; | |
} | |
} | |
$bar = new bar; | |
$bar->greet('jan'); | |
$bar->greet2(); |
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 | |
{ | |
private $name; | |
public function greet2() | |
{ | |
$this->greet('jan'); | |
echo $this->name; | |
} | |
private function greet($name) | |
{ | |
$this->name = $name; | |
} | |
} | |
class bar extends foo | |
{ | |
public function greet() | |
{ | |
echo "Hello"; | |
} | |
} | |
$bar = new bar; | |
$bar->greet(); | |
$bar->greet2(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment