3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Mailer {} class SwiftAdapter implements Mailer {} class ZendAdapter implements Mailer {} class NativeAdapter implements Mailer {} class MailerFactory { /** * Select the best available mailer * * @return Mailer */ public function select() { if (class_exists('SwiftMailer')) { // or whatever, cba looking up actual class names return $this->createSwiftAdapter(); } else if (class_exists('Zend_Mail')) { return $this->createZendAdapter(); } else { return $this->createNativeAdapter(); } } /** * Explicitly create a Swift adapter * * @return SwiftAdapter */ public function createSwiftAdapter() { return new SwiftAdapter; // can deal with args here if needed } /** * Explicitly create a Zend adapter * * @return ZendAdapter */ public function createZendAdapter() { return new ZendAdapter; // can deal with args here if needed } /** * Explicitly create a native adapter * * @return NativeAdapter */ public function createNativeAdapter() { return new NativeAdapter; // can deal with args here if needed } }
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:
47.64 ms | 401 KiB | 8 Q