3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TextOperator { const CONTAINS = 'contains'; const CONTAINS_NOT = 'containsnot'; } abstract class Condition { protected $operator; protected $value; public function __construct($value, $operator) { $this->setValue($value); $this->setOperator($operator); } abstract public function setOperator($operator); abstract public function setValue($value); public function getOperator() { return $this->operator; } public function getValue() { return $this->value; } } class TextCondition extends Condition { public function __construct($value, $operator = TextOperator::CONTAINS) { parent::__construct($value, $operator); } public function setOperator($operator) { $this->operator = TextOperator::get($operator); } public function setValue($value) { $this->value = (string)$value; } } $cond1 = new TextCondition(TextOperator::CONTAINS, 'foo'); $cond2 = new TextCondition(TextOperator::CONTAINS, 'bar'); var_dump($cond1, $cond2);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined method TextOperator::get() in /in/GkOCD:43 Stack trace: #0 /in/GkOCD(17): TextCondition->setOperator('foo') #1 /in/GkOCD(38): Condition->__construct('contains', 'foo') #2 /in/GkOCD(52): TextCondition->__construct('contains', 'foo') #3 {main} thrown in /in/GkOCD on line 43
Process exited with code 255.

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