3v4l.org

run code in 300+ PHP versions simultaneously
<?php // define the common interface interface StorageInterface { function store($key, $value); function retrieve($key); } // implement functionality common to descendants abstract class Storage implements StorageInterface { protected function normalizeKey($key) { return $normalizedKey; } protected function someOtherUtilityFunction() {} } // concrete implementations class S3 extends Storage { protected $backend; public function __construct(S3object $backend) { $this->backend = $backend; } public function store($key, $value) {} public function retrieve($key) {} } class DBX extends Storage { protected $backend; public function __construct(DBXobject $backend) { $this->backend = $backend; } public function store($key, $value) {} public function retrieve($key) {} } // maybe GCS is a completely different beast and can't/shouldn't descend from Storage class GoogleCloudStorage implements StorageInterface { protected $backend; public function __construct(GCSobject $backend) { $this->backend = $backend; } public function store($key, $value) {} public function retrieve($key) {} } // so long as the object implements the interface we don't care about its parentage class MyThingThatNeedsStorage { public function __construct(StorageInterface $storage) {} public function doSomething() { $this->storage->retrieve('foo'); } }
Output for git.master, git.master_jit, rfc.property-hooks

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:
62.49 ms | 401 KiB | 8 Q