3v4l.org

run code in 300+ PHP versions simultaneously
<?php function buildQuery($retrievables, $table, $limit = 0, $conditions = "", $orderCondition = "", $orderDirection = "") { $query = "SELECT $retrievables FROM $table"; // if we have conditions - add them to the query $query .= ($conditions != "" ? " WHERE " . $conditions : ""); // if we have a limit - add it to the query $query .= ($limit != 0 ? " LIMIT " . $limit : ""); // if we have to order the results - add it to the query $query .= ($orderCondition != "" ? " ORDER BY " . $orderCondition . " " . $orderDirection : ""); // first we create a "dictionary" which translates $niceValues that are used throughout the code // to $realValues which are used in the MySQL database // since the $realValues are different in every table - we must account to that switch ($table) { case 'usersTable': $niceValues = array("userID", "userName", "userAge", "userLocation", "userSex", "userIntention", "usersTable"); $realValues = array("uid", "uname", "user_bdate", "user_from", "name", "user_intrest", "nuke_users"); // yeah - the field "name" is really the sex of the user break; case 'articlesTable': $niceValues = array("articleID", "articleTitle", "articleLead", "articleBody", "articlesTable"); $realValues = array("sid", "title", "hometext", "bodytext", "nuke_stories"); break; default: $realValues = array(); } // we then replace $niceValues with $realValues $modifiedQuery = str_ireplace($niceValues, $realValues, $query); return $modifiedQuery; } $retrievables = "uid, user_bdate, user_from, uname, moody"; print_r(buildQuery($retrievables, "usersTable", "", "uid=$userID")); ?>

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).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.70.0110.00416.88
8.3.60.0040.01216.88
8.3.50.0120.00917.44
8.3.40.0190.00018.66
8.3.30.0090.00918.84
8.3.20.0000.00818.77
8.3.10.0040.00420.65
8.3.00.0070.00419.40
8.2.180.0100.00717.00
8.2.170.0160.00622.96
8.2.160.0040.01121.15
8.2.150.0000.00724.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0080.00019.36
8.2.110.0040.00720.95
8.2.100.0090.00318.03
8.2.90.0060.00319.29
8.2.80.0040.00418.03
8.2.70.0050.00317.63
8.2.60.0090.00017.93
8.2.50.0080.00018.07
8.2.40.0040.00418.13
8.2.30.0000.01018.13
8.2.20.0040.00417.87
8.2.10.0000.00717.81
8.2.00.0050.00317.80
8.1.280.0030.01025.92
8.1.270.0080.00024.66
8.1.260.0060.00926.35
8.1.250.0050.00328.09
8.1.240.0030.00622.63
8.1.230.0070.00720.88
8.1.220.0000.00817.77
8.1.210.0060.00318.95
8.1.200.0030.00617.23
8.1.190.0040.00417.38
8.1.180.0060.00318.10
8.1.170.0050.00318.82
8.1.160.0040.00418.91
8.1.150.0040.00418.59
8.1.140.0040.00817.48
8.1.130.0070.00017.90
8.1.120.0000.00817.43
8.1.110.0050.00017.46
8.1.100.0000.00917.46
8.1.90.0040.00417.47
8.1.80.0000.00717.39
8.1.70.0030.00317.41
8.1.60.0000.00817.64
8.1.50.0040.00417.47
8.1.40.0040.00417.43
8.1.30.0050.00217.50
8.1.20.0050.00317.66
8.1.10.0030.00517.51
8.1.00.0030.00617.42
8.0.300.0040.00419.87
8.0.290.0000.00816.75
8.0.280.0000.00718.48
8.0.270.0000.00717.28
8.0.260.0000.00616.88
8.0.250.0000.00817.01
8.0.240.0000.00716.91
8.0.230.0000.00717.01
8.0.220.0030.00316.95
8.0.210.0000.00817.00
8.0.200.0060.00017.04
8.0.190.0080.00017.01
8.0.180.0000.00717.00
8.0.170.0090.00017.01
8.0.160.0040.00416.99
8.0.150.0050.00316.91
8.0.140.0050.00316.84
8.0.130.0060.00013.38
8.0.120.0070.00016.89
8.0.110.0000.00816.83
8.0.100.0040.00416.80
8.0.90.0000.00716.85
8.0.80.0080.01216.92
8.0.70.0000.00716.93
8.0.60.0000.00716.80
8.0.50.0040.00416.94
8.0.30.0090.01216.98
8.0.20.0110.00917.30
8.0.10.0080.00016.95
8.0.00.0100.00816.77
7.4.330.0050.00013.02
7.4.320.0060.00016.54
7.4.300.0000.00716.57
7.4.290.0000.00816.68
7.4.280.0080.00016.64
7.4.270.0040.00416.58
7.4.260.0000.00713.24
7.4.250.0040.00416.48
7.4.240.0050.00316.52
7.4.230.0030.00316.37
7.4.220.0130.00616.50
7.4.210.0090.00716.63
7.4.200.0080.00016.42
7.4.190.0030.00316.41
7.4.160.0100.00516.64
7.4.150.0090.00916.68
7.4.140.0090.00816.54
7.4.130.0070.01316.51
7.4.120.0110.00616.48
7.4.110.0130.00316.69
7.4.100.0080.00816.68
7.4.90.0060.01316.54
7.4.80.0100.00716.63
7.4.70.0060.01616.59
7.4.60.0100.00516.50
7.4.50.0030.00316.45
7.4.40.0030.00916.30
7.4.30.0030.01316.48
7.4.00.0070.00715.13
7.3.330.0050.00013.24
7.3.320.0030.00313.45
7.3.310.0000.00716.38
7.3.300.0050.00216.44
7.3.290.0060.00916.42
7.3.280.0100.00516.45
7.3.270.0030.01316.68
7.3.260.0100.00816.53
7.3.250.0120.00716.41
7.3.240.0080.00816.30
7.3.230.0100.00616.29
7.3.210.0100.00716.45
7.3.200.0090.00719.39
7.3.190.0110.00916.28
7.3.180.0090.00616.52
7.3.170.0070.01116.59
7.3.160.0100.00716.59
7.3.120.0110.00314.91
7.2.330.0060.01116.46
7.2.320.0100.01316.61
7.2.310.0120.01216.90
7.2.300.0110.00716.79
7.2.290.0120.00416.83
7.2.60.0050.00816.67
7.2.00.0060.00619.68
7.1.200.0060.00615.58
7.1.70.0040.00417.34
7.1.60.0140.01019.40
7.1.50.0060.00917.05
7.1.00.0070.05322.45
7.0.200.0000.00816.79
7.0.140.0130.06321.95
7.0.120.0070.06022.16
7.0.60.0070.05320.02
7.0.50.0070.06317.90
7.0.40.0130.05020.38
7.0.30.0200.06020.04
7.0.20.0230.04020.15
7.0.10.0130.08020.22
7.0.00.0070.03720.22
5.6.280.0070.06721.09
5.6.210.0030.06720.63
5.6.200.0170.07718.16
5.6.190.0030.06320.63
5.6.180.0270.04020.39
5.6.170.0370.07020.47
5.6.160.0100.08720.45
5.6.150.0100.09018.24
5.6.140.0070.08318.18
5.6.130.0100.04718.15
5.6.120.0170.08321.03
5.6.110.0030.09021.03
5.6.100.0070.07720.91
5.6.90.0200.06721.12
5.6.80.0070.08320.44
5.5.350.0330.07320.44
5.5.340.0030.05017.94
5.5.330.0030.08320.57
5.5.320.0170.08020.42
5.5.310.0330.08020.37
5.5.300.0170.06718.07
5.5.290.0070.05018.03
5.5.280.0070.06020.68
5.5.270.0070.05720.64
5.5.260.0100.09020.84
5.5.250.0100.04020.69
5.5.240.0000.07720.27
5.4.450.0070.08019.25
5.4.440.0030.05719.57
5.4.430.0070.06719.17
5.4.420.0000.07019.56
5.4.410.0070.07319.20
5.4.400.0030.04019.16
5.4.390.0000.04319.14
5.4.380.0030.03719.24
5.4.370.0070.03318.92
5.4.360.0000.04019.25
5.4.350.0030.04718.86
5.4.340.0030.03719.24
5.4.320.0030.03719.14
5.4.310.0030.03719.15
5.4.300.0070.03319.07
5.4.290.0030.03719.07
5.4.280.0030.03719.23
5.4.270.0000.04019.15
5.4.260.0130.02718.97
5.4.250.0070.03319.20
5.4.240.0070.03318.92
5.4.230.0030.03719.14
5.4.220.0070.03719.07
5.4.210.0000.04019.23
5.4.200.0030.03719.16
5.4.190.0130.02718.91
5.4.180.0070.03319.11
5.4.170.0030.03718.91
5.4.160.0030.03719.13
5.4.150.0030.04718.91
5.4.140.0000.04716.29
5.4.130.0070.06716.54
5.4.120.0030.03716.42
5.4.110.0130.06016.53
5.4.100.0070.05316.47
5.4.90.0030.07716.39
5.4.80.0030.04316.65
5.4.70.0030.04716.29
5.4.60.0030.04316.31
5.4.50.0070.07316.39
5.4.40.0000.05316.38
5.4.30.0070.04316.40
5.4.20.0100.06316.36
5.4.10.0170.06016.29
5.4.00.0070.04015.70
5.3.290.0030.03714.73
5.3.280.0030.03714.66
5.3.270.0100.03314.62
5.3.260.0030.03714.67
5.3.250.0070.03314.68
5.3.240.0030.07314.62
5.3.230.0070.06314.62
5.3.220.0030.06014.66
5.3.210.0030.04714.50
5.3.200.0000.08314.65
5.3.190.0200.04014.59
5.3.180.0100.07314.61
5.3.170.0030.07714.61
5.3.160.0030.04714.62
5.3.150.0130.06314.73
5.3.140.0100.05714.59
5.3.130.0000.08014.56
5.3.120.0070.07314.56
5.3.110.0070.05714.60
5.3.100.0070.07714.05
5.3.90.0070.06714.03
5.3.80.0070.05014.00
5.3.70.0130.06714.19
5.3.60.0000.08014.07
5.3.50.0070.07713.98
5.3.40.0070.07714.03
5.3.30.0070.05714.01
5.3.20.0000.05013.69
5.3.10.0100.03313.69
5.3.00.0070.05313.66
5.2.170.0100.05711.21
5.2.160.0070.04011.20
5.2.150.0100.05711.20
5.2.140.0100.05311.18
5.2.130.0070.04711.12
5.2.120.0130.03011.27
5.2.110.0030.05311.17
5.2.100.0070.06011.16
5.2.90.0030.06311.15
5.2.80.0100.04711.13
5.2.70.0070.06311.19
5.2.60.0070.05311.14
5.2.50.0000.04011.03
5.2.40.0030.06711.17
5.2.30.0100.05011.02
5.2.20.0070.06310.98
5.2.10.0100.03310.91
5.2.00.0030.06310.79
5.1.60.0030.02710.06
5.1.50.0100.04710.06
5.1.40.0070.04010.00
5.1.30.0030.03710.35
5.1.20.0000.03010.25
5.1.10.0070.02310.04
5.1.00.0070.05010.05
5.0.50.0030.0438.59
5.0.40.0000.0208.43
5.0.30.0100.0578.31
5.0.20.0000.0408.29
5.0.10.0070.0378.26
5.0.00.0030.0538.20
4.4.90.0000.0407.79
4.4.80.0030.0337.79
4.4.70.0030.0237.79
4.4.60.0000.0277.79
4.4.50.0000.0207.79
4.4.40.0000.0607.79
4.4.30.0000.0337.79
4.4.20.0030.0137.79
4.4.10.0030.0337.79
4.4.00.0000.0277.79
4.3.110.0030.0207.79
4.3.100.0000.0237.79
4.3.90.0070.0307.79
4.3.80.0030.0237.79
4.3.70.0000.0177.79
4.3.60.0070.0177.79
4.3.50.0000.0207.79
4.3.40.0000.0307.79
4.3.30.0000.0237.79
4.3.20.0000.0377.79
4.3.10.0000.0277.79
4.3.00.0000.0177.79

preferences:
68.74 ms | 401 KiB | 5 Q