3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements Countable { public $prop1; private $propa=2; protected $propx=3; public $prop4 = array(1,2,3,4); public function Greet() { return 'hello world'; } public function getCount() { $res = (array) $this; return count($res); } public function count() { return $this->getCount(); } } $t = new Test; echo $t->Greet(),"\n"; echo count( (array) $t),"\n"; echo $t->getCount(),"\n"; echo count($t),"\n"; var_dump( get_object_vars($t) ); $ao = (ArrayObject) $t; echo count($ao);
Output for 5.4.0 - 5.4.28
Parse error: syntax error, unexpected '$t' (T_VARIABLE) in /in/qiL7a on line 28
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE in /in/qiL7a on line 28
Process exited with code 255.

preferences:
174.63 ms | 1395 KiB | 65 Q