3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace SimonEq; interface ImageInterface { function getFileName(); } class Image implements ImageInterface { private $fileName; public function __construct($fileName) { $this->fileName = $fileName; } public function getFileName() { return $this->fileName; } } interface TransformationInterface { function transform(ImageInterface $image); } class TransformationAggregate implements TransformationInterface { private $transformationArray = []; public function __construct($transformationArray) { $this->transformationArray = $transformationArray; } public function transform(ImageInterface $image) { foreach ($this->transformationArray as $transformation) { $transformation->transform($image); } } } class CropTransformation implements TransformationInterface { private $width; private $height; public function __construct($width, $height) { $this->width = (int) $width; $this->height = (int) $height; } public function transform(ImageInterface $image) { printf('Image "%s" transformed with %s' . PHP_EOL, $image->getFileName(), print_r($this, true)); } } class ResizeTransformation implements TransformationInterface { private $width; private $height; private $resample; public function __construct($width, $height, $resample) { $this->width = (int) $width; $this->height = (int) $height; $this->resample = (bool) $resample; } public function transform(ImageInterface $image) { printf('Image "%s" transformed with %s' . PHP_EOL, $image->getFileName(), print_r($this, true)); } } class WatermarkTransformation implements TransformationInterface { private $image; public function __construct(ImageInterface $image) { $this->image = $image; } public function transform(ImageInterface $image) { printf('Image "%s" transformed with %s' . PHP_EOL, $image->getFileName(), print_r($this, true)); } } $image = new Image('FluffyCat.jpg'); $transformation = new TransformationAggregate([ new CropTransformation(200, 400), new WatermarkTransformation(new Image('MyWaterMark.png')), new ResizeTransformation(100, 200, true), ]); $transformation->transform($image);
Output for git.master, git.master_jit, rfc.property-hooks
Image "FluffyCat.jpg" transformed with SimonEq\CropTransformation Object ( [width:SimonEq\CropTransformation:private] => 200 [height:SimonEq\CropTransformation:private] => 400 ) Image "FluffyCat.jpg" transformed with SimonEq\WatermarkTransformation Object ( [image:SimonEq\WatermarkTransformation:private] => SimonEq\Image Object ( [fileName:SimonEq\Image:private] => MyWaterMark.png ) ) Image "FluffyCat.jpg" transformed with SimonEq\ResizeTransformation Object ( [width:SimonEq\ResizeTransformation:private] => 100 [height:SimonEq\ResizeTransformation:private] => 200 [resample:SimonEq\ResizeTransformation:private] => 1 )

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:
44.39 ms | 402 KiB | 8 Q