php2go/fixtures/0005-inheritance.php

37 lines
441 B
PHP
Raw Normal View History

2020-04-05 06:05:32 +00:00
<?php
class Base {
protected $mX;
protected function __construct($x) {
$this->mX = $x;
}
2020-04-05 06:23:52 +00:00
public function Val() {
return 3;
}
2020-04-05 06:05:32 +00:00
static function TheStatic() {}
}
class Child extends Base {
protected $mY;
public function __construct($x) {
super($x);
$this->mY = 0;
}
2020-04-05 06:23:52 +00:00
public function Val() {
return 4;
}
public function Combine() {
return $this->Val() + parent::Val();
}
2020-04-05 06:05:32 +00:00
}
2020-04-05 06:23:52 +00:00
echo (new Child(0))->Combine();