3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function OdeberZKosiku($id_polozka) { global $session_user; $id_polozka=intval($id_polozka); $query = mysql_query(" DELETE FROM ".TBL_PREFIX."kosik_polozky WHERE id_polozka='$id_polozka' and id_user='$session_user' ") or die(err(1)); } function PridejDoKosikuHromadne($id_produkty, $pocet) { $pridano=false; for ($f=0;$f<count($id_produkty);$f++) { if ($pocet[$f]>0) { $vystup=PridejDoKosiku($id_produkty[$f],$pocet[$f]); if ($vystup) $pridano=true; } } return $pridano; } function PridejDoKosiku($add_id, $pocet) { global $session_user; //vypoÄ?Ă­tĂĄm cenu a zjistĂ­m zda produkt existuje, kvĹŻli POST podvrĹženĂ­ $query = mysql_query(" SELECT p.id, p.cena1, m.id_poplatek FROM ".TBL_PREFIX."produkty p JOIN ".TBL_PREFIX."produkty_matky m ON p.id_matka=m.id_matka WHERE p.id='$add_id' and m.web='".__WEB__."' and m.aktivni=1 ") or die(err(1)); if (mysql_num_rows($query)==1) { $row = mysql_fetch_array($query); $cena=CenaProZakaznika($row['id']); //poÄ?et produktĹŻ v koĹĄĂ­ku $query_pocet = mysql_query("SELECT pocet FROM ".TBL_PREFIX."kosik_polozky WHERE id_produkt='$add_id' and id_user='$session_user' ") or die(err(1)); if (mysql_num_rows($query_pocet)==0) { //poplatek je bez DPH, pĹ?ed vloĹženĂ­m do koĹĄĂ­ku musĂ­m DPH pĹ?idat... if ($cena['druh_cena']==__BEZ_DPH__) { $cena['poplatek']=($cena['poplatek']*$cena['dph_sazba']/100)+$cena['poplatek']; // $cena['poplatek']=$cena['poplatek']*$cena['dph_sazba']/100)+$cena['poplatek']; } //nenĂ­ jeĹĄtÄ? v koĹĄĂ­ku........insert $vloz=mysql_query(" INSERT INTO ".TBL_PREFIX."kosik_polozky (id_polozka, id_user, id_produkt, cena_bez_dph, cena_s_dph, dph, cena_poplatek, id_poplatek, pocet, cas) VALUES ( '', '$session_user', '$add_id', '".$cena['cena_bez_dph']."', '".$cena['cena_s_dph']."', '".$cena['dph_sazba']."', '".$cena['poplatek']."', '".$row['id_poplatek']."', '$pocet', now() ) ") or die(err(1)); } else { //je v koĹĄĂ­ku........update $row_pocet = mysql_fetch_array($query_pocet); $pridat=$row_pocet['pocet']+$pocet; $vloz=mysql_query(" UPDATE ".TBL_PREFIX."kosik_polozky SET pocet='$pridat' WHERE id_produkt='$add_id' and id_user='$session_user' LIMIT 1 ") or die(err(1)); } return true; //header("Location: ".__URL__."kosik.html"); //exit(); } else return false; } function PrepocitejKosik($id,$pocet) { global $session_user; //mazĂĄnĂ­ vĹĄeho mysql_query(" DELETE FROM ".TBL_PREFIX."kosik_polozky WHERE id_user='$session_user' ") or die(err(1)); for ($f=0;$f<count($id);$f++) { //vypoÄ?Ă­tĂĄm cenu a zjistĂ­m zda produkt existuje, kvĹŻli POST podvrĹženĂ­ $query = mysql_query(" SELECT p.id, m.id_poplatek FROM ".TBL_PREFIX."produkty p JOIN ".TBL_PREFIX."produkty_matky m ON p.id_matka=m.id_matka WHERE p.id='$id[$f]' and m.web='".__WEB__."' ") or die(err(1)); if (mysql_num_rows($query)==1) { $row = mysql_fetch_array($query); $cena=CenaProZakaznika($row['id']); } if ($pocet[$f]>0) { //poplatek je bez DPH, pĹ?ed vloĹženĂ­m do koĹĄĂ­ku musĂ­m DPH pĹ?idat... if ($cena['druh_cena']==__BEZ_DPH__) { $cena['poplatek']=($cena['poplatek']*$cena['dph_sazba']/100)+$cena['poplatek']; // $cena['poplatek']=$cena['poplatek']*$cena['dph_sazba']/100)+$cena['poplatek']; } $vloz=mysql_query(" INSERT INTO ".TBL_PREFIX."kosik_polozky (id_polozka, id_user, id_produkt, cena_bez_dph, cena_s_dph, dph, cena_poplatek, id_poplatek, pocet, cas) VALUES ('','$session_user', '$id[$f]', '".$cena['cena_bez_dph']."', '".$cena['cena_s_dph']."', '".$cena['dph_sazba']."', '".$cena['poplatek']."', '".$row['id_poplatek']."', '$pocet[$f]', now() ) ") or die(err(1)); } } } //prepocita celkovou cenu v session v 1 kroku objednavky pri zadani slevoveho kuponu function NastavSessionCeny() { global $session_user; $usk = __UPLATNOVAT_SLEVOVE_KODY_NA_ZBOZI_KTERE_NENI_SKLADEM__ == 'Ano' ? 1: 0; $query_kosik = mysql_query(" SELECT k.*, IF (p.uplatnit_slevovy_kod = 1 AND ((p.kusu_skladem > 0 AND ".$usk." = 0) OR ".$usk."=1),1,0) AS uplatnit_slevovy_kod FROM ".TBL_PREFIX."kosik_polozky k JOIN ".TBL_PREFIX."produkty p ON p.id=k.id_produkt JOIN ".TBL_PREFIX."produkty_matky m ON p.id_matka=m.id_matka JOIN ".TBL_PREFIX."menu menu ON menu.id_matka=m.id_matka and vychozi=1 WHERE id_user='$session_user' and m.aktivni=1 and p.aktivni=1 and m.web='".__WEB__."' GROUP BY p.id ORDER BY k.id_polozka ") or die(mysql_error()); $soucet_s_dph = $soucet_bez_dph = 0; if (mysql_num_rows($query_kosik)==0) return false; while($kosik=mysql_fetch_array($query_kosik)) { $poplatek=$kosik['cena_poplatek']; //pokud je zadan slevovy kod, pak probehne odecteni slevy, je u produktu, ktere nemaji priznak "Na tento produkt lze uplatnit slevovĂ˝ kupĂłn" $sleva_koef = __MODUL_SLEVOVE_KODY__ && $kosik['uplatnit_slevovy_kod'] == 1 && isset($_SESSION['obj']['slevovy_kod_sleva']) && $_SESSION['obj']['slevovy_kod_sleva'] > 0 ? 1 - ($_SESSION['obj']['slevovy_kod_sleva'] / 100) : 1; $soucet_s_dph=$soucet_s_dph+((($kosik['cena_s_dph']*$sleva_koef)+$poplatek)*$kosik['pocet']); $soucet_bez_dph=$soucet_bez_dph+$kosik['cena_bez_dph']*$sleva_koef*$kosik['pocet']; } $_SESSION['obj']['celkova_cena']=$soucet_s_dph; $_SESSION['obj']['celkem_bez_dph']=$soucet_bez_dph; return true; } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.2.60.0000.01316.61
7.2.00.0060.00818.92
7.1.200.0050.00515.47
7.1.100.0030.00717.89
7.1.70.0080.00016.67
7.1.60.0130.01319.46
7.1.50.0100.01316.86
7.1.00.0030.07022.45
7.0.200.0040.00416.50
7.0.140.0000.05022.00
7.0.100.0070.08720.06
7.0.90.0200.07320.05
7.0.80.0230.07720.04
7.0.70.0200.07719.99
7.0.60.0070.07320.07
7.0.50.0130.08020.40
7.0.40.0100.05320.15
7.0.30.0030.06020.09
7.0.20.0030.05720.14
7.0.10.0130.07720.11
7.0.00.0100.08020.07
5.6.280.0000.07321.16
5.6.250.0070.04720.57
5.6.240.0070.07720.55
5.6.230.0100.07720.65
5.6.220.0100.07720.53
5.6.210.0070.05020.67
5.6.200.0070.09721.10
5.6.190.0030.04321.15
5.6.180.0070.07021.16
5.6.170.0030.07721.03
5.6.160.0130.07021.11
5.6.150.0130.08321.20
5.6.140.0000.09021.16
5.6.130.0130.07721.08
5.6.120.0030.07320.98
5.6.110.0030.07021.16
5.6.100.0030.08721.21
5.6.90.0070.08021.15
5.6.80.0100.07020.55
5.6.70.0070.07320.48
5.6.60.0070.06720.44
5.6.50.0070.07720.53
5.6.40.0100.07320.55
5.6.30.0030.08320.60
5.6.20.0200.05320.48
5.6.10.0070.08020.37
5.6.00.0070.07020.43
5.5.380.0230.06020.55
5.5.370.0070.05020.51
5.5.360.0100.07320.50
5.5.350.0030.09020.51
5.5.340.0130.06320.92
5.5.330.0070.08320.70
5.5.320.0100.07720.82
5.5.310.0170.06320.85
5.5.300.0070.04320.85
5.5.290.0130.07020.89
5.5.280.0030.08720.86
5.5.270.0030.08320.88
5.5.260.0070.08020.79
5.5.250.0130.07320.51
5.5.240.0070.08020.33
5.5.230.0130.08320.32
5.5.220.0070.07720.36
5.5.210.0030.08020.25
5.5.200.0130.08020.29
5.5.190.0100.04320.33
5.5.180.0130.08020.34
5.5.160.0130.04020.02
5.5.150.0130.07720.14
5.5.140.0070.06720.31
5.5.130.0030.06720.29
5.5.120.0030.08020.14
5.5.110.0130.07720.23
5.5.100.0070.04720.19
5.5.90.0100.04320.21
5.5.80.0070.07720.17
5.5.70.0130.07320.14
5.5.60.0070.07020.12
5.5.50.0070.04720.16
5.5.40.0070.07720.12
5.5.30.0070.07020.15
5.5.20.0030.05320.14
5.5.10.0130.06320.09
5.5.00.0100.05720.17
5.4.450.0100.07319.46
5.4.440.0200.06719.46
5.4.430.0100.07319.45
5.4.420.0130.07319.57
5.4.410.0070.08019.20
5.4.400.0130.06719.18
5.4.390.0070.07319.04
5.4.380.0100.06319.04
5.4.370.0070.06718.89
5.4.360.0130.07318.88
5.4.350.0100.07719.14
5.4.340.0000.09018.90
5.4.320.0170.06719.16
5.4.310.0200.06019.18
5.4.300.0100.07318.84
5.4.290.0070.07319.16
5.4.280.0070.07719.04
5.4.270.0170.05719.23
5.4.260.0100.07319.10
5.4.250.0100.06018.84
5.4.240.0100.07719.09
5.4.230.0030.05019.03
5.4.220.0130.06719.17
5.4.210.0130.06719.09
5.4.200.0100.05019.15
5.4.190.0100.07318.93
5.4.180.0070.07319.11
5.4.170.0070.07319.14
5.4.160.0100.06319.01
5.4.150.0030.08319.03
5.4.140.0030.07716.39
5.4.130.0100.07016.41
5.4.120.0130.07016.38
5.4.110.0100.07016.49
5.4.100.0170.03016.48
5.4.90.0030.06716.34
5.4.80.0130.06316.47
5.4.70.0070.07016.55
5.4.60.0170.03016.47
5.4.50.0070.03316.45
5.4.40.0070.04316.42
5.4.30.0100.07016.45
5.4.20.0070.07716.53
5.4.10.0000.08016.55
5.4.00.0100.06715.93