3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Set { public function __construct(array $spec, $arg1 = null, $arg2 = null) { if (isset($spec[0]) && is_array($spec[0]) { // was called like Set::createFromArray([['foo'=>'bar'], false, 64]); } else { // was called like new Set(['foo'=>'bar'], false, 64) } } } class SetFactory { public function create(array $map, $arg1, $arg2) { return new Set($map, $arg1, $arg2); } public function createFromArray(array $spec) { return new Set($spec); } }
Output for 5.3.0 - 5.3.27, 5.4.0 - 5.4.18, 5.5.0 - 5.5.2
Parse error: syntax error, unexpected '{' in /in/OXgTk on line 7
Process exited with code 255.

preferences:
194.57 ms | 1400 KiB | 57 Q