3v4l.org

run code in 300+ PHP versions simultaneously
<?php function filterLabel($label) { $filtered = trim($label); $array = array($filtered => 1); $filtered = key($array); if ($filtered === false) { throw new UnexpectedValueException('Unable to filter %s', var_export($label, true)); } return $filtered; } $data = array("foo", "0foo", 0, "0", "00", 1, NULL, FALSE, new SimpleXMLElement('<root />')); foreach ($data as $index => $label) { printf("==== %d ====\n", $index); var_dump($label, filterLabel($label)); }
Output for git.master, git.master_jit, rfc.property-hooks
==== 0 ==== string(3) "foo" string(3) "foo" ==== 1 ==== string(4) "0foo" string(4) "0foo" ==== 2 ==== int(0) int(0) ==== 3 ==== string(1) "0" int(0) ==== 4 ==== string(2) "00" string(2) "00" ==== 5 ==== int(1) int(1) ==== 6 ==== Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /in/TTdCX on line 5 NULL string(0) "" ==== 7 ==== bool(false) string(0) "" ==== 8 ==== object(SimpleXMLElement)#1 (0) { } string(0) ""

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:
40.41 ms | 402 KiB | 8 Q