3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class FullName implements JsonSerializable { public $forename; public $surname; public function __construct(string $forename, string $surname) { $this->forename = $this->validateAndNormalize($forename); $this->surname = $this->validateAndNormalize($surname); } private function validateAndNormalize($name) : string { return ucwords($name); } public function jsonSerialize() { return $this->forename . ' ' . $this->surname; } } $o = new FullName('aaa', 'bbb'); $returnValues = array( 'id' => 42, 'name' => $o, 'message' => 'The professional has been updated' ); echo json_encode($returnValues);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of FullName::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/3OPa3 on line 22 {"id":42,"name":"Aaa Bbb","message":"The professional has been updated"}

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