3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { protected $protectedVariable; public function __construct() { $this->protectedVariable = 'this belongs to test class'; } } $x = new class (10) extends Test { public $holder; public $publicVar; public function __construct($classArg) { parent::__construct(); $this->holder = $classArg; } public function multiplyByNo($multiplier) { return $this->holder * $multiplier; } }; $templateFunction = function ($someNumber) { return $this->multiplyByNo($someNumber); }; var_dump($x->call($templateFunction, 10));

preferences:
61.52 ms | 402 KiB | 5 Q