3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=0); class Test { private array $array; private string $string; public function __construct() { // $this->array = 1; // Fatal error $this->array = (array) 1; // ok, [1] $this->string = 1; // ok, '1' } public function getArray(): array { return $this->array; // ok } public function getAnotherArray(): array { // return 1; // Fatal error return (array) 1; // ok, [1] } public function getString(): string { return $this->string; } } $test = new Test(); var_dump($test->getArray(), $test->getAnotherArray(), $test->getString());
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { [0]=> int(1) } array(1) { [0]=> int(1) } string(1) "1"

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:
39.48 ms | 405 KiB | 5 Q