一段代码片段,帮助您更多地了解抽象类中的属性
<?php
抽象类 anotherAbsClass
{
static $stProp = 'qwerty'; protected $prProp = 'walrus';
protected function callMe() {
echo 'On call: ' . $this->prProp . PHP_EOL;
}
abstract protected function abc($arg1, $arg2);
abstract public function getJunk($arg1, $arg2, $arg3, $junkCollector = true);
}
类 someChildClass 扩展 anotherAbsClass
{
function __construct() {
echo $this->callMe() . PHP_EOL; }
protected function abc($val1, $val) {
}
function getJunk($val1, $val2, $val3, $b = false) { }
}
echo anotherAbsClass::$stProp; $objTest = new someChildClass; ?>