3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ColorChanger { public $lastColors = []; public function blackMethod() { $colors = implode(', ', $this->lastColors); echo "blackMethod(); Last colors: {$colors}\n"; $this->lastColors[] = 'black'; return $this; } public function whiteMethod() { $colors = implode(', ', $this->lastColors); echo "whiteMethod(); Last colors: {$colors}\n"; $this->lastColors[] = 'white'; return $this; } public function colourMethod() { $colors = implode(', ', $this->lastColors); $lastColor = $this->lastColors[count($this->lastColors)-1]; echo "colourMethod(): {$colors} (Last: $lastColor)\n"; $this->lastColors = []; } } $c = new ColorChanger(); $c->blackMethod()->colourMethod(); $c->whiteMethod()->colourMethod(); $c->blackMethod()->whiteMethod()->blackMethod()->colourMethod();
Output for git.master_jit, git.master, rfc.property-hooks
blackMethod(); Last colors: colourMethod(): black (Last: black) whiteMethod(); Last colors: colourMethod(): white (Last: white) blackMethod(); Last colors: whiteMethod(); Last colors: black blackMethod(); Last colors: black, white colourMethod(): black, white, black (Last: black)

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:
154.36 ms | 406 KiB | 5 Q