<?php error_reporting(E_ALL); class A { protected $x; public function __construct( $x ) { $this->x = $x; } protected function f() { return $this->x; } public function m() { return A::f(); } } class B extends A { protected function f() { return 2 * $this->x; } } $a = new A(1); echo 'A: ' . $a->m() . PHP_EOL; $b = new B(1); echo 'B: ' . $b->m();
You have javascript disabled. You will not be able to edit any code.