3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Bar { } class Foo { private $bar; public function __construct(Bar $bar) { $this->bar = $bar; } } $reflect = new ReflectionClass('foo'); $constructor = $reflect->getConstructor(); $bar = new Bar; $aBar = [$bar]; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = new Foo($bar); } $t2 = microtime(true); echo 'new keyword: ' . ($t2-$t1) . "\n\n"; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceArgs([$bar]); } $t2 = microtime(true); echo 'newinstanceargs: ' . ($t2-$t1) . "\n\n"; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceWithoutConstructor(); $constructor->invokeArgs($foo, [$bar]); } $t2 = microtime(true); echo 'newinstancewithoutconstructor: ' . ($t2-$t1) . "\n\n"; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = new Foo(...$aBar); } $t2 = microtime(true); echo 'vradic: ' . ($t2-$t1) . "\n\n";
based on 1a1A2
Output for 7.1.0
new keyword: 0.001662015914917 newinstanceargs: 0.0034689903259277 newinstancewithoutconstructor: 0.0040149688720703 vradic: 0.0017938613891602
Output for 7.0.14
new keyword: 0.0017168521881104 newinstanceargs: 0.0032799243927002 newinstancewithoutconstructor: 0.004249095916748 vradic: 0.0017759799957275
Output for 7.0.6
new keyword: 0.0013871192932129 newinstanceargs: 0.0030930042266846 newinstancewithoutconstructor: 0.003410816192627 vradic: 0.0014550685882568
Output for 7.0.5
new keyword: 0.0013048648834229 newinstanceargs: 0.0026741027832031 newinstancewithoutconstructor: 0.0032639503479004 vradic: 0.0013279914855957
Output for 7.0.4
new keyword: 0.0010781288146973 newinstanceargs: 0.0022099018096924 newinstancewithoutconstructor: 0.002579927444458 vradic: 0.0011429786682129
Output for 7.0.3
new keyword: 0.001492977142334 newinstanceargs: 0.0030989646911621 newinstancewithoutconstructor: 0.0035381317138672 vradic: 0.0016138553619385
Output for 7.0.2
new keyword: 0.0010979175567627 newinstanceargs: 0.0023880004882812 newinstancewithoutconstructor: 0.0027840137481689 vradic: 0.0011699199676514
Output for 7.0.1
new keyword: 0.0017521381378174 newinstanceargs: 0.0035929679870605 newinstancewithoutconstructor: 0.0040819644927979 vradic: 0.0017650127410889
Output for 7.0.0
new keyword: 0.0017168521881104 newinstanceargs: 0.0036098957061768 newinstancewithoutconstructor: 0.0041160583496094 vradic: 0.001788854598999
Output for 5.6.28
new keyword: 0.0044670104980469 newinstanceargs: 0.0080809593200684 newinstancewithoutconstructor: 0.0097088813781738 vradic: 0.0043509006500244
Output for 5.6.21
new keyword: 0.0030720233917236 newinstanceargs: 0.0062470436096191 newinstancewithoutconstructor: 0.0069429874420166 vradic: 0.0037779808044434
Output for 5.6.20
new keyword: 0.0036931037902832 newinstanceargs: 0.0071430206298828 newinstancewithoutconstructor: 0.0080771446228027 vradic: 0.0043461322784424
Output for 5.6.19
new keyword: 0.0025548934936523 newinstanceargs: 0.0045640468597412 newinstancewithoutconstructor: 0.0054669380187988 vradic: 0.002683162689209
Output for 5.6.18
new keyword: 0.0024130344390869 newinstanceargs: 0.0044689178466797 newinstancewithoutconstructor: 0.005159854888916 vradic: 0.0026059150695801
Output for 5.6.17
new keyword: 0.0037949085235596 newinstanceargs: 0.0073120594024658 newinstancewithoutconstructor: 0.0083999633789062 vradic: 0.0044989585876465
Output for 5.6.16
new keyword: 0.0034558773040771 newinstanceargs: 0.008018970489502 newinstancewithoutconstructor: 0.010138988494873 vradic: 0.0054318904876709
Output for 5.6.15
new keyword: 0.0038471221923828 newinstanceargs: 0.007803201675415 newinstancewithoutconstructor: 0.0080251693725586 vradic: 0.0045080184936523
Output for 5.6.14
new keyword: 0.002626895904541 newinstanceargs: 0.0051398277282715 newinstancewithoutconstructor: 0.0059280395507812 vradic: 0.0032660961151123
Output for 5.6.13
new keyword: 0.0041060447692871 newinstanceargs: 0.008030891418457 newinstancewithoutconstructor: 0.008573055267334 vradic: 0.0045042037963867
Output for 5.6.12
new keyword: 0.0025959014892578 newinstanceargs: 0.0050489902496338 newinstancewithoutconstructor: 0.0058419704437256 vradic: 0.0045008659362793
Output for 5.6.11
new keyword: 0.0038599967956543 newinstanceargs: 0.0075321197509766 newinstancewithoutconstructor: 0.0090351104736328 vradic: 0.0044691562652588
Output for 5.6.10
new keyword: 0.0038208961486816 newinstanceargs: 0.0073621273040771 newinstancewithoutconstructor: 0.0083179473876953 vradic: 0.0044600963592529
Output for 5.6.9
new keyword: 0.0039050579071045 newinstanceargs: 0.0078108310699463 newinstancewithoutconstructor: 0.0084779262542725 vradic: 0.0047950744628906
Output for 5.6.8
new keyword: 0.0039811134338379 newinstanceargs: 0.0080130100250244 newinstancewithoutconstructor: 0.008915901184082 vradic: 0.0047779083251953
Output for 5.6.7
new keyword: 0.0032980442047119 newinstanceargs: 0.0064480304718018 newinstancewithoutconstructor: 0.0072660446166992 vradic: 0.0038599967956543
Output for 5.5.24 - 5.5.35
Parse error: syntax error, unexpected '.' in /in/d2DkD on line 56
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '.', expecting ')' in /in/d2DkD on line 56
Process exited with code 255.
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/d2DkD on line 19
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/d2DkD on line 19
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/d2DkD on line 7
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/d2DkD on line 7
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/d2DkD on line 7
Process exited with code 255.