3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class derp { public function __construct($v) { $this->num = $v; } public function getNum() { return $this->num; } } $d = array(); for($i = 0; $i < 100; $i++) { $d[] = new derp(rand(1,100)); } $nums = array_reduce($d, function($nums, $derp) { if ($nums === null) { $nums = 0; } $nums += $derp->getNum(); return $nums; }); var_dump($nums);
Output for 7.1.0
int(4968)
Output for 7.0.14
int(4791)
Output for 7.0.6
int(4880)
Output for 5.4.41, 7.0.5
int(4903)
Output for 7.0.4
int(4852)
Output for 7.0.3
int(4772)
Output for 7.0.2
int(5109)
Output for 7.0.1
int(4831)
Output for 7.0.0
int(5465)
Output for 5.6.28
int(4958)
Output for 5.6.21
int(4912)
Output for 5.6.20
int(5311)
Output for 5.6.19
int(4929)
Output for 5.5.29, 5.6.18
int(5016)
Output for 5.6.17
int(4844)
Output for 5.6.16
int(5203)
Output for 5.6.15
int(4879)
Output for 5.6.14
int(4976)
Output for 5.6.13
int(5286)
Output for 5.6.12
int(4822)
Output for 5.6.11
int(4450)
Output for 5.6.10
int(5502)
Output for 5.6.9
int(4614)
Output for 5.6.8
int(4658)
Output for 5.6.7
int(5404)
Output for 5.5.35
int(5232)
Output for 5.5.34
int(4420)
Output for 5.5.33
int(4928)
Output for 5.5.32
int(5220)
Output for 5.5.31
int(5405)
Output for 5.5.30
int(5395)
Output for 5.5.28
int(5020)
Output for 5.5.27
int(4823)
Output for 5.5.26
int(4383)
Output for 5.5.25
int(5303)
Output for 5.5.24
int(4478)
Output for 5.4.45
int(5154)
Output for 5.4.44
int(5223)
Output for 5.4.43
int(5468)
Output for 5.4.42
int(4654)
Output for 5.4.40
int(4971)
Output for 5.4.39
int(4603)
Output for 5.4.38
int(4806)
Output for 5.4.37
int(5382)
Output for 5.4.36
int(5062)
Output for 5.4.35
int(4667)
Output for 5.3.23, 5.4.34
int(5050)
Output for 5.4.32
int(5053)
Output for 5.4.31
int(5259)
Output for 5.4.30
int(4855)
Output for 5.4.29
int(5451)
Output for 5.4.28
int(5493)
Output for 5.4.27
int(5038)
Output for 5.4.26
int(4648)
Output for 5.4.25
int(4690)
Output for 5.4.24
int(4962)
Output for 5.4.23
int(5184)
Output for 5.4.22
int(5507)
Output for 5.4.21
int(5455)
Output for 5.4.20
int(5297)
Output for 5.4.19
int(5197)
Output for 5.4.18
int(4995)
Output for 5.4.17
int(5183)
Output for 5.4.16
int(5310)
Output for 5.4.15
int(4843)
Output for 5.4.14
int(4711)
Output for 5.4.13
int(5046)
Output for 5.4.12
int(5323)
Output for 5.4.11
int(5263)
Output for 5.4.10
int(5017)
Output for 5.4.9
int(4909)
Output for 5.4.8
int(5320)
Output for 5.4.7
int(5111)
Output for 5.4.6
int(4873)
Output for 5.4.5
int(4789)
Output for 5.4.4
int(4981)
Output for 5.4.3
int(4759)
Output for 5.4.2
int(4515)
Output for 5.4.1
int(4652)
Output for 5.4.0
int(5653)
Output for 5.3.29
int(5078)
Output for 5.3.28
int(5102)
Output for 5.3.27
int(4618)
Output for 5.3.26
int(5149)
Output for 5.3.25
int(4948)
Output for 5.3.24
int(5321)
Output for 5.3.22
int(5731)
Output for 5.3.21
int(5186)
Output for 5.3.20
int(4782)
Output for 5.3.19
int(5175)
Output for 5.3.18
int(4861)
Output for 5.3.17
int(4914)
Output for 5.3.16
int(5241)
Output for 5.3.15
int(4681)
Output for 5.3.14
int(5336)
Output for 5.3.13
int(4946)
Output for 5.3.12
int(5121)
Output for 5.3.11
int(5073)
Output for 5.3.10
int(5389)
Output for 5.3.9
int(5085)
Output for 5.3.8
int(5165)
Output for 5.3.7
int(5087)
Output for 5.3.6
int(5358)
Output for 5.3.5
int(5214)
Output for 5.3.4
int(5390)
Output for 5.3.3
int(5229)
Output for 5.3.2
int(5416)
Output for 5.3.1
int(5051)
Output for 5.3.0
int(4960)
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/CtVvE on line 16
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/CtVvE on line 16
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/CtVvE on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/CtVvE on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/CtVvE on line 3
Process exited with code 255.