3v4l.org

run code in 500+ PHP versions simultaneously
<?php final class Word { private $word; public function __construct(string $word) { $this->word = $word; } public function reverse(): self { return new self(strrev($this->word)); } public function __toString() { return $this->word; } } $word = new Word('potato'); echo $word->reverse();

preferences:
86.83 ms | 1764 KiB | 5 Q