3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Iterators\Classes; class FizzBuzz implements \Iterator { protected $pointer = 0; protected $numbers = []; public function __construct($numbers=[]) { $this->numbers = $numbers; return; } public function current() { $returnValue = ''; $returnValue .= ($this->numbers[$this->pointer]%3===0?'Fizz':''); $returnValue .= ($this->numbers[$this->pointer]%5===0?'Buzz':''); $returnValue = (empty($returnValue)?$this->numbers[$this->pointer]:$returnValue); return $returnValue; } public function key() { return $this->pointer; } public function next() { $this->pointer++; return; } public function rewind() { $this->pointer=0; return; } public function valid() { return isset($this->numbers[$this->pointer]); } }; $fizz = new FizzBuzz(); var_dump($fizz);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Iterators\Classes\FizzBuzz::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/HYgI3 on line 13 Deprecated: Return type of Iterators\Classes\FizzBuzz::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/HYgI3 on line 25 Deprecated: Return type of Iterators\Classes\FizzBuzz::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/HYgI3 on line 21 Deprecated: Return type of Iterators\Classes\FizzBuzz::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/HYgI3 on line 35 Deprecated: Return type of Iterators\Classes\FizzBuzz::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/HYgI3 on line 30 object(Iterators\Classes\FizzBuzz)#1 (2) { ["pointer":protected]=> int(0) ["numbers":protected]=> array(0) { } }

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:
34.96 ms | 404 KiB | 8 Q