3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function profile($c, $n = 1000) { $m = 'microtime'; for ($i = $n * is_callable($c), $t = 0;$i--;$w = $m(1), $c(), $t+= ($m(1) - $w) / $n); return $t; } class Foo { protected $foo; protected $bar; protected $baz; } class FooSelfHydratingProxy extends Foo { /** zero-argument constructor since this is just a helper class for hydration */ public function __construct() { } /** * the `Foo` typehint is not part of the interface - here only for the sake of readability/clearness */ public function hydrate($data, Foo $object) { $object->foo = $data['foo']; $object->bar = $data['bar']; $object->baz = $data['baz']; } /** * the `Foo` typehint is not part of the interface - here only for the sake of readability/clearness */ public function extract(Foo $object) { return array('foo' => $object->foo, 'bar' => $object->bar, 'baz' => $object->baz); } } // data $data = array('foo' => 1, 'bar' => 2, 'baz' => 3); // lastguest function dehydrate($obj){ $class = get_class($obj); $exp = var_export($obj,1); return eval('return '.substr($exp,strpos($exp,'(')+1,-1).';'); } function static_hydrate($class,$dry=null){ static $hydrators = array(); $h = '_Hydrator__'.$class; if (empty($hydrators[$class])) { eval("class $h extends $class { static function __hydrate(\$a) { \$o = new $class(); foreach (\$a as \$n=>\$v) \$o->\$n=\$v; return \$o; } } function hydrate_$class(\$o){return $h::__hydrate(\$o);}" ); $hydrators[$class] = true; } return $dry?$h::__hydrate($dry):new $h; } function hydrate($class,$dry=null){ static $hydrators = array(); $h = '_Hydrator__'.$class; if (empty($hydrators[$class])) { eval("class $h extends $class { static function __hydrate(\$a) { \$o = new $class(); foreach (\$a as \$n=>\$v) \$o->\$n=\$v; return \$o; } } function hydrate_$class(\$o){return $h::__hydrate(\$o);}" ); $hydrators[$class] = true; } return $dry?$h::__hydrate($dry):new $h; } $hydrator = new FooSelfHydratingProxy(); echo 'Ocramius: ',profile(function() use ($data,$hydrator) { $hydrated = new Foo(); $hydrator->hydrate($data, $hydrated); })*1E6,PHP_EOL; $hydr = static_hydrate('Foo'); echo 'Lastguest: ',profile(function() use ($data) { hydrate_Foo($data); })*1E6,PHP_EOL; $hydr = static_hydrate('Foo'); echo 'Lastguest: ',profile(function() use ($data,$hydr) { $hydr->__hydrate($data); })*1E6,PHP_EOL; $foo = hydrate_Foo($data); $foo_s = serialize($foo); echo 'Lastguest: ',profile(function() use ($data,$foo_s) { unserialize($foo_s); })*1E6,PHP_EOL;
Output for 7.1.0
Ocramius: 0.64206123352051 Lastguest: 0.68593025207519 Lastguest: 0.70023536682129 Lastguest: 1.4786720275879
Output for 7.0.14
Ocramius: 0.73742866516113 Lastguest: 0.73885917663574 Lastguest: 0.73194503784179 Lastguest: 1.4858245849609
Output for 7.0.6
Ocramius: 0.51355361938476 Lastguest: 0.63252449035644 Lastguest: 0.56910514831543 Lastguest: 1.2831687927246
Output for 7.0.5
Ocramius: 0.52332878112793 Lastguest: 0.65040588378906 Lastguest: 0.60963630676269 Lastguest: 1.352310180664
Output for 7.0.4
Ocramius: 0.50878524780273 Lastguest: 0.60796737670898 Lastguest: 0.57744979858398 Lastguest: 1.1892318725586
Output for 7.0.3
Ocramius: 0.49495697021484 Lastguest: 0.57625770568848 Lastguest: 0.54430961608887 Lastguest: 1.2431144714355
Output for 7.0.2
Ocramius: 0.41580200195312 Lastguest: 0.4878044128418 Lastguest: 0.46753883361816 Lastguest: 1.0368824005127
Output for 7.0.1
Ocramius: 0.33926963806152 Lastguest: 0.40459632873535 Lastguest: 0.40078163146973 Lastguest: 0.83637237548828
Output for 7.0.0
Ocramius: 0.33783912658691 Lastguest: 0.39315223693848 Lastguest: 0.38266181945801 Lastguest: 0.85210800170898
Output for hhvm-3.12.0
Ocramius: 0.76818466186523 Lastguest: 0.90456008911133 Lastguest: 0.78153610229492 Lastguest: 0.59056282043457
Output for hhvm-3.10.0
Ocramius: 1.2280941009521 Lastguest: 1.2693405151367 Lastguest: 1.3089179992676 Lastguest: 1.2991428375244
Output for 5.6.28
Ocramius: 1.1539459228515 Lastguest: 1.7311573028564 Lastguest: 1.6152858734131 Lastguest: 2.455472946167
Output for 5.6.21
Ocramius: 1.1746883392334 Lastguest: 1.9466876983642 Lastguest: 1.4984607696533 Lastguest: 2.2070407867432
Output for 5.6.20
Ocramius: 1.0483264923096 Lastguest: 1.1777877807617 Lastguest: 1.15966796875 Lastguest: 1.9090175628662
Output for 5.6.19
Ocramius: 0.89979171752929 Lastguest: 1.234769821167 Lastguest: 1.1982917785644 Lastguest: 1.7695426940918
Output for 5.6.18
Ocramius: 0.79154968261719 Lastguest: 1.1014938354492 Lastguest: 1.0371208190918 Lastguest: 1.4686584472656
Output for 5.6.17
Ocramius: 0.78415870666504 Lastguest: 0.90575218200683 Lastguest: 0.88405609130859 Lastguest: 1.4464855194092
Output for 5.6.16
Ocramius: 1.0576248168945 Lastguest: 1.2128353118896 Lastguest: 1.1544227600097 Lastguest: 1.8179416656494
Output for 5.6.15
Ocramius: 1.2338161468506 Lastguest: 1.4526844024658 Lastguest: 1.4035701751709 Lastguest: 2.0730495452881
Output for 5.6.14
Ocramius: 1.1730194091797 Lastguest: 1.392126083374 Lastguest: 1.3496875762939 Lastguest: 2.1710395812988
Output for 5.6.13
Ocramius: 0.99682807922363 Lastguest: 1.15966796875 Lastguest: 1.1200904846191 Lastguest: 1.7244815826416
Output for 5.6.12
Ocramius: 0.7326602935791 Lastguest: 1.4162063598633 Lastguest: 0.81968307495117 Lastguest: 1.4536380767822
Output for 5.6.11
Ocramius: 1.2509822845459 Lastguest: 1.3656616210937 Lastguest: 1.3816356658935 Lastguest: 2.1471977233887
Output for 5.6.10
Ocramius: 1.0261535644531 Lastguest: 1.1882781982422 Lastguest: 1.1720657348633 Lastguest: 1.8174648284912
Output for 5.6.9
Ocramius: 0.96511840820312 Lastguest: 1.124382019043 Lastguest: 1.1048316955566 Lastguest: 1.7974376678467
Output for 5.6.8
Ocramius: 1.2497901916504 Lastguest: 1.3711452484131 Lastguest: 1.3802051544189 Lastguest: 2.1266937255859
Output for 5.5.35
Ocramius: 1.0449886322021 Lastguest: 1.3434886932373 Lastguest: 1.3241767883301 Lastguest: 1.9288063049316
Output for 5.5.34
Ocramius: 1.176118850708 Lastguest: 1.431941986084 Lastguest: 1.3744831085205 Lastguest: 1.9388198852539
Output for 5.5.33
Ocramius: 0.95152854919433 Lastguest: 1.3577938079834 Lastguest: 1.3623237609863 Lastguest: 1.711368560791
Output for 5.5.32
Ocramius: 1.0695457458496 Lastguest: 1.333475112915 Lastguest: 1.2781620025635 Lastguest: 1.8839836120605
Output for 5.5.31
Ocramius: 0.76603889465332 Lastguest: 0.95200538635254 Lastguest: 0.91361999511718 Lastguest: 1.4033317565918
Output for 5.5.30
Ocramius: 0.96726417541503 Lastguest: 1.2037754058838 Lastguest: 1.1613368988037 Lastguest: 1.6536712646484
Output for 5.5.29
Ocramius: 0.75364112854004 Lastguest: 0.92983245849609 Lastguest: 0.94890594482422 Lastguest: 1.4979839324951
Output for 5.5.28
Ocramius: 1.15966796875 Lastguest: 1.4774799346924 Lastguest: 1.4522075653076 Lastguest: 2.1789073944092
Output for 5.5.27
Ocramius: 1.2526512145996 Lastguest: 1.4710426330566 Lastguest: 1.4729499816894 Lastguest: 2.1789073944092
Output for 5.5.26
Ocramius: 0.93722343444824 Lastguest: 0.95176696777343 Lastguest: 0.90980529785156 Lastguest: 1.3751983642578
Output for 5.5.25
Ocramius: 1.3220310211181 Lastguest: 1.5287399291992 Lastguest: 1.4622211456299 Lastguest: 2.1491050720215
Output for 5.5.24
Ocramius: 0.76866149902344 Lastguest: 0.93770027160644 Lastguest: 0.89836120605468 Lastguest: 1.4417171478271
Output for 5.4.45
Ocramius: 1.2247562408447 Lastguest: 1.7096996307373 Lastguest: 1.6267299652099 Lastguest: 3.6780834197998
Output for 5.4.44
Ocramius: 1.2454986572265 Lastguest: 1.9266605377197 Lastguest: 1.694917678833 Lastguest: 2.363920211792
Output for 5.4.43
Ocramius: 1.1582374572754 Lastguest: 1.8737316131592 Lastguest: 1.565933227539 Lastguest: 2.2726058959961
Output for 5.4.42
Ocramius: 1.2938976287842 Lastguest: 3.6408901214599 Lastguest: 1.7814636230469 Lastguest: 2.4137496948242
Output for 5.4.41
Ocramius: 1.2881755828857 Lastguest: 1.8379688262939 Lastguest: 2.3438930511474 Lastguest: 3.3988952636718
Output for 5.4.40
Ocramius: 1.2435913085937 Lastguest: 1.7545223236084 Lastguest: 1.7745494842529 Lastguest: 2.1710395812988
Output for 5.4.39
Ocramius: 1.4753341674804 Lastguest: 1.7910003662109 Lastguest: 1.7642974853516 Lastguest: 2.2387504577637
Output for 5.4.38
Ocramius: 1.4219284057617 Lastguest: 1.7797946929932 Lastguest: 1.5802383422851 Lastguest: 2.2180080413818
Output for 5.4.37
Ocramius: 1.2798309326172 Lastguest: 1.3051033020019 Lastguest: 1.2068748474121 Lastguest: 1.9207000732422
Output for 5.4.36
Ocramius: 0.99110603332519 Lastguest: 1.4147758483887 Lastguest: 1.4317035675049 Lastguest: 1.9142627716064
Output for 5.4.35
Ocramius: 1.0700225830078 Lastguest: 1.4393329620361 Lastguest: 1.3542175292969 Lastguest: 1.6748905181885
Output for 5.4.34
Ocramius: 1.0359287261963 Lastguest: 1.52587890625 Lastguest: 1.3570785522461 Lastguest: 1.7063617706299
Output for 5.4.32
Ocramius: 1.1055469512939 Lastguest: 1.699686050415 Lastguest: 1.4290809631347 Lastguest: 1.6682147979736
Output for 5.4.31
Ocramius: 1.0764598846435 Lastguest: 1.3926029205322 Lastguest: 1.2753009796142 Lastguest: 1.7709732055664
Output for 5.4.30
Ocramius: 1.0931491851806 Lastguest: 1.4846324920654 Lastguest: 1.2550354003906 Lastguest: 1.6512870788574
Output for 5.4.29
Ocramius: 0.97918510437011 Lastguest: 1.410961151123 Lastguest: 1.279354095459 Lastguest: 1.7311573028564
Output for 5.4.28
Ocramius: 2.2006034851074 Lastguest: 3.4224987030029 Lastguest: 3.1516551971435 Lastguest: 4.1289329528808
Output for 5.4.27
Ocramius: 1.1091232299805 Lastguest: 1.5106201171875 Lastguest: 1.4982223510742 Lastguest: 1.8763542175293
Output for 5.4.26
Ocramius: 0.99587440490722 Lastguest: 1.5256404876709 Lastguest: 1.5544891357422 Lastguest: 1.6756057739258
Output for 5.4.25
Ocramius: 1.0933876037598 Lastguest: 1.3811588287353 Lastguest: 1.3213157653808 Lastguest: 1.5950202941894
Output for 5.4.24
Ocramius: 1.3961791992187 Lastguest: 1.9316673278808 Lastguest: 2.5444030761718 Lastguest: 2.361536026001
Output for 5.4.23
Ocramius: 1.0278224945068 Lastguest: 1.509428024292 Lastguest: 1.4510154724121 Lastguest: 1.6613006591797
Output for 5.4.22
Ocramius: 1.0769367218017 Lastguest: 1.4348030090332 Lastguest: 1.3535022735596 Lastguest: 1.7211437225342
Output for 5.4.21
Ocramius: 1.0466575622558 Lastguest: 1.4405250549316 Lastguest: 1.4445781707763 Lastguest: 1.704216003418
Output for 5.4.20
Ocramius: 1.0554790496826 Lastguest: 1.5404224395752 Lastguest: 1.446008682251 Lastguest: 1.7745494842529
Output for 5.4.19
Ocramius: 1.023530960083 Lastguest: 1.4567375183105 Lastguest: 1.347541809082 Lastguest: 1.5978813171387
Output for 5.4.18
Ocramius: 1.1415481567383 Lastguest: 1.5664100646972 Lastguest: 1.4772415161133 Lastguest: 1.6689300537109
Output for 5.4.17
Ocramius: 1.293420791626 Lastguest: 1.5769004821777 Lastguest: 1.5039443969726 Lastguest: 1.9021034240723
Output for 5.4.16
Ocramius: 1.2161731719971 Lastguest: 1.5342235565185 Lastguest: 1.4736652374267 Lastguest: 1.6474723815918
Output for 5.4.15
Ocramius: 1.1250972747803 Lastguest: 1.5888214111328 Lastguest: 1.6045570373535 Lastguest: 1.6226768493652
Output for 5.4.14
Ocramius: 1.0244846343994 Lastguest: 1.4450550079346 Lastguest: 1.3735294342041 Lastguest: 1.6474723815918
Output for 5.4.13
Ocramius: 1.0297298431396 Lastguest: 1.5020370483398 Lastguest: 1.4848709106445 Lastguest: 2.0539760589599
Output for 5.4.12
Ocramius: 0.99778175354004 Lastguest: 1.6143321990967 Lastguest: 1.3654232025146 Lastguest: 1.7867088317871
Output for 5.4.11
Ocramius: 1.0621547698975 Lastguest: 1.6152858734131 Lastguest: 1.4338493347168 Lastguest: 1.7628669738769
Output for 5.4.10
Ocramius: 1.1098384857178 Lastguest: 1.6231536865234 Lastguest: 1.4228820800781 Lastguest: 1.8508434295654
Output for 5.4.9
Ocramius: 1.0750293731689 Lastguest: 1.786470413208 Lastguest: 1.5742778778076 Lastguest: 1.7504692077637
Output for 5.4.8
Ocramius: 1.5215873718261 Lastguest: 1.6801357269287 Lastguest: 1.5766620635986 Lastguest: 1.8301010131836
Output for 5.4.7
Ocramius: 1.3952255249023 Lastguest: 1.6572475433349 Lastguest: 1.7316341400146 Lastguest: 1.8012523651123
Output for 5.4.6
Ocramius: 1.7104148864746 Lastguest: 1.5177726745605 Lastguest: 1.3699531555176 Lastguest: 1.6474723815918
Output for 5.4.5
Ocramius: 1.1003017425537 Lastguest: 1.5277862548828 Lastguest: 1.4379024505615 Lastguest: 1.7528533935547
Output for 5.4.4
Ocramius: 1.0538101196289 Lastguest: 1.5740394592285 Lastguest: 1.4243125915527 Lastguest: 1.7015933990478
Output for 5.4.3
Ocramius: 1.1942386627197 Lastguest: 1.6031265258789 Lastguest: 1.4338493347168 Lastguest: 1.932144165039
Output for 5.4.2
Ocramius: 1.6231536865234 Lastguest: 1.6443729400635 Lastguest: 1.3918876647949 Lastguest: 2.0313262939453
Output for 5.4.1
Ocramius: 1.0871887207031 Lastguest: 1.4801025390625 Lastguest: 1.3761520385742 Lastguest: 1.7960071563721
Output for 5.4.0
Ocramius: 1.176118850708 Lastguest: 1.5180110931396 Lastguest: 1.3990402221679 Lastguest: 1.8758773803711
Output for 5.3.29
Ocramius: 1.457929611206 Lastguest: 1.9934177398682 Lastguest: 1.7552375793457 Lastguest: 1.4550685882568
Output for 5.3.28
Ocramius: 1.8033981323242 Lastguest: 1.9919872283936 Lastguest: 1.7824172973633 Lastguest: 1.5342235565185
Output for 5.3.27
Ocramius: 1.4071464538574 Lastguest: 1.8830299377441 Lastguest: 1.9369125366211 Lastguest: 1.5590190887451
Output for 5.3.26
Ocramius: 1.631498336792 Lastguest: 2.0153522491455 Lastguest: 1.7406940460205 Lastguest: 1.5676021575928
Output for 5.3.25
Ocramius: 1.6045570373535 Lastguest: 1.9371509552002 Lastguest: 1.8239021301269 Lastguest: 1.5311241149902
Output for 5.3.24
Ocramius: 1.5037059783935 Lastguest: 2.145528793335 Lastguest: 1.7931461334228 Lastguest: 1.5931129455566
Output for 5.3.23
Ocramius: 1.4550685882568 Lastguest: 1.7995834350586 Lastguest: 1.6682147979736 Lastguest: 1.6331672668457
Output for 5.3.22
Ocramius: 1.3864040374756 Lastguest: 1.957893371582 Lastguest: 1.6107559204101 Lastguest: 1.4135837554931
Output for 5.3.21
Ocramius: 1.4309883117676 Lastguest: 2.4077892303467 Lastguest: 1.7883777618408 Lastguest: 1.8734931945801
Output for 5.3.20
Ocramius: 1.5816688537597 Lastguest: 2.1133422851562 Lastguest: 1.8341541290283 Lastguest: 1.5575885772705
Output for 5.3.19
Ocramius: 1.5108585357666 Lastguest: 2.0482540130615 Lastguest: 1.7788410186767 Lastguest: 1.5139579772949
Output for 5.3.18
Ocramius: 1.5716552734375 Lastguest: 1.9583702087402 Lastguest: 1.7483234405517 Lastguest: 1.5146732330322
Output for 5.3.17
Ocramius: 1.565933227539 Lastguest: 2.1240711212158 Lastguest: 2.0170211791992 Lastguest: 1.554012298584
Output for 5.3.16
Ocramius: 1.4448165893555 Lastguest: 1.9309520721436 Lastguest: 1.7380714416504 Lastguest: 1.5218257904053
Output for 5.3.15
Ocramius: 1.3871192932129 Lastguest: 1.9857883453369 Lastguest: 1.7657279968262 Lastguest: 1.4750957489013
Output for 5.3.14
Ocramius: 1.3723373413086 Lastguest: 1.8882751464844 Lastguest: 1.6980171203613 Lastguest: 1.4195442199707
Output for 5.3.13
Ocramius: 1.4245510101318 Lastguest: 1.7924308776855 Lastguest: 1.6317367553711 Lastguest: 1.4498233795166
Output for 5.3.12
Ocramius: 1.4636516571045 Lastguest: 1.8975734710693 Lastguest: 1.6005039215088 Lastguest: 1.4495849609375
Output for 5.3.11
Ocramius: 1.4123916625976 Lastguest: 1.8367767333984 Lastguest: 1.6119480133056 Lastguest: 1.4235973358154
Output for 5.3.10
Ocramius: 1.5392303466797 Lastguest: 1.866340637207 Lastguest: 1.6748905181885 Lastguest: 1.5108585357666
Output for 5.3.9
Ocramius: 1.4591217041015 Lastguest: 1.9574165344238 Lastguest: 1.6539096832275 Lastguest: 1.4936923980713
Output for 5.3.8
Ocramius: 1.4073848724365 Lastguest: 1.8019676208496 Lastguest: 1.753568649292 Lastguest: 1.6121864318848
Output for 5.3.7
Ocramius: 1.4927387237549 Lastguest: 1.7547607421875 Lastguest: 1.6531944274902 Lastguest: 1.5201568603515
Output for 5.3.6
Ocramius: 1.5068054199219 Lastguest: 1.8424987792969 Lastguest: 1.7755031585693 Lastguest: 1.5475749969482
Output for 5.3.5
Ocramius: 1.594066619873 Lastguest: 1.8651485443115 Lastguest: 1.7194747924805 Lastguest: 1.6920566558838
Output for 5.3.4
Ocramius: 1.6341209411621 Lastguest: 1.9354820251465 Lastguest: 1.8072128295898 Lastguest: 1.6031265258789
Output for 5.3.3
Ocramius: 1.6078948974609 Lastguest: 1.9834041595459 Lastguest: 1.805305480957 Lastguest: 1.8432140350342
Output for 5.3.2
Ocramius: 1.4955997467041 Lastguest: 2.023458480835 Lastguest: 1.8630027770996 Lastguest: 1.711368560791
Output for 5.3.1
Ocramius: 1.5695095062256 Lastguest: 2.0163059234619 Lastguest: 1.8830299377441 Lastguest: 1.6851425170898
Output for 5.3.0
Ocramius: 1.4295578002929 Lastguest: 1.8754005432129 Lastguest: 1.6837120056152 Lastguest: 1.5847682952881
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /in/QK8Wu on line 69
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /in/QK8Wu on line 69
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/QK8Wu on line 11
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/QK8Wu on line 11
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/QK8Wu on line 11
Process exited with code 255.