3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class ColorShifter{ private $colors; public function __construct($colors) { $this->colors = new ArrayObject($colors); } public function getNext() { $this->colors->getIterator()->next(); return $this->colors->getIterator()->current(); } } $imageWidth = 300; $imageHeight = 350; $image = imagecreate($imageWidth, $imageHeight); $red = imagecolorallocate($image, 255, 10 , 10); $blue = imagecolorallocate($image, 10, 10 , 255); $gold = imagecolorallocate($image, 255, 240, 0); $colors = new ArrayObject(array($red, $blue, $gold)); $iterator = $colors->getIterator(); for($i = 0; $i<$imageWidth; $i += 10){ if(!$iterator->valid()) $iterator->rewind(); $iterator->next(); imagefilledrectangle($image, 0 , 0, $imageWidth - $i , $imageHeight-$i, $iterator->current()); } $iterator->next(); imagefilledrectangle($image, 0, 0, 10, 10, $iterator->current()); imagepng($image); header('Content-Type: image/png'); echo $image;
based on vp9Sa
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function imagecreate() in /in/5hYuX:21 Stack trace: #0 {main} thrown in /in/5hYuX on line 21
Process exited with code 255.
Output for 5.3.21 - 5.6.28
Fatal error: Call to undefined function imagecreate() in /in/5hYuX on line 21
Process exited with code 255.