3v4l.org

run code in 300+ PHP versions simultaneously
<?php class c { protected $type = null; public function __construct($in) { $this->type = $in; } public function __toString() { return $this->type; } static function getInstanceA() { static $a = null; if ($a === null) { $a = new c('A'); } return $a; } static function getInstanceB() { static $b = null; if ($b === null) { $b = new c('B'); } return $b; } static function someA() { static $a = null; $a = 'this is fucked'; return $a; } } $z = c::someA(); $my_a = c::getInstanceA(); $my_b = c::getInstanceB(); echo $my_a; echo $my_b; echo $z;
Output for git.master, git.master_jit, rfc.property-hooks
ABthis is fucked

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
59.37 ms | 401 KiB | 8 Q