Skip to content

Instantly share code, notes, and snippets.

@hrach
Last active August 29, 2015 14:03
Show Gist options
  • Save hrach/4c63222f61d252aa627a to your computer and use it in GitHub Desktop.
Save hrach/4c63222f61d252aa627a to your computer and use it in GitHub Desktop.
test inheritance php
<?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();
<?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