[PHP]クラスの継承を利用するサンプル
書式
class 継承先のクラス名 extends 継承元のクラス名
サンプルコード
<?php
class User
{
public function getMsgA()
{
return "test AA011";
}
}
class Employee extends User
{
public function getMsgB()
{
return "test BB022";
}
}
$cft = new Employee();
print $cft->getMsgA();
print $cft->getMsgB();
<?php
class User
{
public function getMsgA()
{
return "test AA011";
}
}
class Employee extends User
{
public function getMsgB()
{
return "test BB022";
}
}
$cft = new Employee();
print $cft->getMsgA();
print $cft->getMsgB();
<?php class User { public function getMsgA() { return "test AA011"; } } class Employee extends User { public function getMsgB() { return "test BB022"; } } $cft = new Employee(); print $cft->getMsgA(); print $cft->getMsgB();