3v4l.org

run code in 300+ PHP versions simultaneously
<?php class StringNotEmptyType { public string $s; public function __construct(string $s) { $s = trim($s); if ($s === '') { throw new Exception('String must not be emtpy'); } $this->s = $s; } public function __toString() : string { return $this->s; } public static function create(string $s) : self { return new self($s); } } class Something { public StringNotEmptyType $s; } $okay = new Something(); $okay->s = StringNotEmptyType::create('not empty'); echo $okay->s; $okay = new Something(); $okay->s = StringNotEmptyType::create('');
Output for git.master, git.master_jit, rfc.property-hooks
not empty Fatal error: Uncaught Exception: String must not be emtpy in /in/1LqIj:11 Stack trace: #0 /in/1LqIj(25): StringNotEmptyType->__construct('') #1 /in/1LqIj(42): StringNotEmptyType::create('') #2 {main} thrown in /in/1LqIj on line 11
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:
43.76 ms | 401 KiB | 8 Q