3v4l.org

run code in 300+ PHP versions simultaneously
<?php class P { function r($o,$p) { if($v=get_object_vars($o)&&@$v=$v[$p]) return$v; $m=['set','get','has','is','_']; do { if($s=get_class_methods($o)&&in_array($a=current($m).$p),$s)return$o->$a(); } while(next($m)); throw new Exception(); } } class A { private $a = 'hello'; protected function getA() { return $this->a; } } $a = new A(); $p = new P(); echo $p->r($a, 'a');
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected ',' in /in/Dc6iL on line 13
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected '[' in /in/Dc6iL on line 10
Process exited with code 255.

preferences:
193.05 ms | 1395 KiB | 67 Q