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(2, 12); $fizz->current();
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/u7aYD 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/u7aYD 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/u7aYD 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/u7aYD 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/u7aYD on line 30 Warning: Trying to access array offset on value of type int in /in/u7aYD on line 16 Warning: Trying to access array offset on value of type int in /in/u7aYD on line 17
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/u7aYD 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/u7aYD 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/u7aYD 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/u7aYD 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/u7aYD on line 30 Warning: Trying to access array offset on int in /in/u7aYD on line 16 Warning: Trying to access array offset on int in /in/u7aYD on line 17

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:
48.91 ms | 403 KiB | 8 Q