3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); final class Foo implements \Stringable { private function __construct(public readonly string $value) { } public static function fromString(string $string): self { return new self($string); } /** * {@inheritdoc} */ public function __toString(): string { return $this->value; } } $options = [ Foo::fromString('c'), Foo::fromString('b'), Foo::fromString('a'), Foo::fromString('ccc'), Foo::fromString('bcc'), ]; uasort($options, strnatcasecmp(...)); var_dump($options); var_dump(strnatcasecmp(Foo::fromString('c'), Foo::fromString('b')));
Output for git.master_jit, git.master, rfc.property-hooks
array(5) { [2]=> object(Foo)#3 (1) { ["value"]=> string(1) "a" } [1]=> object(Foo)#2 (1) { ["value"]=> string(1) "b" } [4]=> object(Foo)#5 (1) { ["value"]=> string(3) "bcc" } [0]=> object(Foo)#1 (1) { ["value"]=> string(1) "c" } [3]=> object(Foo)#4 (1) { ["value"]=> string(3) "ccc" } } Fatal error: Uncaught TypeError: strnatcasecmp(): Argument #1 ($string1) must be of type string, Foo given in /in/GPV8l:33 Stack trace: #0 /in/GPV8l(33): strnatcasecmp(Object(Foo), Object(Foo)) #1 {main} thrown in /in/GPV8l on line 33
Process exited with code 255.

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