3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo() { $array = [ 'color' => 'blue', 'size' => 'medium', ]; // Using extract. extract($array); var_dump($color); // Not using extract. var_dump($array['color']); $color = $array['color']; var_dump($color); } function bar( $color, $size ) { // Using compact. $array = compact('color', 'size'); var_dump($array); // Not using compact. $array = [ 'color' => $color, 'size' => $size, ]; var_dump($array); $array = []; foreach (['color', 'size'] as $name) { if (isset($$name)) { $array[$name] = $$name; } } var_dump($array); } foo(); bar('blue', 'medium');
Output for git.master, git.master_jit, rfc.property-hooks
string(4) "blue" string(4) "blue" string(4) "blue" array(2) { ["color"]=> string(4) "blue" ["size"]=> string(6) "medium" } array(2) { ["color"]=> string(4) "blue" ["size"]=> string(6) "medium" } array(2) { ["color"]=> string(4) "blue" ["size"]=> string(6) "medium" }

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