3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Div { private array $content = []; private function __construct() { } public static function tag(): self { return new self(); } public function content(... $content) { $new = clone $this; $new->content = array_values($content); return $new; } private function render(): string { $content = ''; foreach ($this->content as $item) { if ($item instanceof Generator) { foreach ($item as $genItem) { $content .= $genItem; } } else { $content .= $item; } } return '<div>' . $content . '</div>'; } final public function __toString(): string { return $this->render(); } } $items = ['blue', 'green', 'red']; echo Div::tag()->content( 'Collors', '<br>', (static function() use ($items): Generator { foreach ($items as $item) { yield Div::tag()->content($item); } })() );
Output for git.master, git.master_jit, rfc.property-hooks
<div>Collors<br><div>blue</div><div>green</div><div>red</div></div>

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:
115.75 ms | 1334 KiB | 4 Q