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(15); echo $fizz->current(); echo $fizz->key(); echo $fizz->next(); echo $fizz-rewind();
Output for git.master, git.master_jit
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/ecRel 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/ecRel 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/ecRel 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/ecRel 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/ecRel on line 30 Warning: Trying to access array offset on value of type int in /in/ecRel on line 16 Warning: Trying to access array offset on value of type int in /in/ecRel on line 17 FizzBuzz0 Fatal error: Uncaught ArgumentCountError: rewind() expects exactly 1 argument, 0 given in /in/ecRel:47 Stack trace: #0 /in/ecRel(47): rewind() #1 {main} thrown in /in/ecRel on line 47
Process exited with code 255.
Output for 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/ecRel 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/ecRel 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/ecRel 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/ecRel 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/ecRel on line 30 Warning: Trying to access array offset on int in /in/ecRel on line 16 Warning: Trying to access array offset on int in /in/ecRel on line 17 FizzBuzz0 Fatal error: Uncaught ArgumentCountError: rewind() expects exactly 1 argument, 0 given in /in/ecRel:47 Stack trace: #0 /in/ecRel(47): rewind() #1 {main} thrown in /in/ecRel on line 47
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:
36.92 ms | 402 KiB | 8 Q