<html lang="ko">
<head>
<meta charset="UTF-8">
<title>PHP OOP</title>
</head>
<body>
class A
{
public $property = "class A";
public function showProperty()
{
echo $this->property."<br>";
}
}
class B extends A // 클래스 A를 상속 받음.
{
public $property = "class B";
public function showProperty() // 클래스 A의 메소드를 오버라이딩
{
echo "hello ".$this->property ."<br>";
}
}
$a = new A();
$a->showProperty(); // 클래스 A의 메소드 호출
$b = new B();
$b->showProperty(); // 클래스 B의 메소드 호출
</body>
</html>