3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface intf{ public function setVar($a); public function getVar(); } class A implements intf{ private $A; public function setVar($a){ $this->A=$a; } public function getVar(){ return $this->A; } } class B extends Abs{ private $B; public function setVar($a){ $this->B=$a; } public function getVar(){ return $this->B; } } abstract class Abs{ abstract public function setVar($a); abstract public function getVar(); public function getDouble($a){ return $a*2; } } $A=new A(); $B=new B(); $A->setVar(2); echo ' Class A: '.$A->getVar(); $B->setVar(4); echo ' Class B: '.$B->getVar(); echo ' Class B Double: '.$B->getDouble($B->getVar());
based on jlZB7
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
Class A: 2 Class B: 4 Class B Double: 8