3v4l.org

run code in 300+ PHP versions simultaneously
<?php function buildQuery($retrievables, $table, $conditions = "", $limit = 0, $order = "") { $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 // 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 'users': $niceValues = ["userID", "userName", "userAge", "userLocation", "userSex", "userIntention", "usersTable"]; $realValues = ["uid", "uname", "user_bdate", "user_from", "name", "user_intrest", "nuke_users"]; // yeah - the field "name" is really the sex of the user break; case 'users': $niceValues = ["articleID", "articleTitle", "articleLeadingText", "articleBodyText"]; $realValues = ["sid", "title", "hometext", "bodytext"]; break; default: $realValues = []; } // we then replace $niceValues with $realValues $modifiedQuery = str_ireplace($niceValues, $realValues, $query); return $modifiedQuery; } print_r(buildQuery("userID, userAge, userSex", "usersTable", 10)); ?>

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.60.0110.00416.88
8.3.50.0120.00817.44
8.3.40.0070.00718.64
8.3.30.0120.00318.96
8.3.20.0000.00818.73
8.3.10.0000.00820.66
8.3.00.0000.00819.50
8.2.180.0140.01016.63
8.2.170.0140.00322.96
8.2.160.0090.00619.03
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0090.00020.65
8.2.110.0030.00620.54
8.2.100.0080.00417.91
8.2.90.0040.00419.46
8.2.80.0000.00819.46
8.2.70.0040.00417.63
8.2.60.0030.00618.03
8.2.50.0000.01118.07
8.2.40.0080.00020.07
8.2.30.0030.00618.29
8.2.20.0080.00017.95
8.2.10.0050.00217.86
8.2.00.0060.00317.80
8.1.280.0140.00325.92
8.1.270.0040.00423.99
8.1.260.0000.00926.35
8.1.250.0040.00428.09
8.1.240.0060.01623.97
8.1.230.0000.01321.98
8.1.220.0050.00317.78
8.1.210.0060.00318.77
8.1.200.0090.00017.38
8.1.190.0040.00417.55
8.1.180.0000.00818.10
8.1.170.0040.00418.76
8.1.160.0030.00518.85
8.1.150.0030.00618.69
8.1.140.0040.00417.45
8.1.130.0040.00417.90
8.1.120.0040.00417.55
8.1.110.0000.00717.53
8.1.100.0070.00017.57
8.1.90.0050.00217.54
8.1.80.0000.00717.47
8.1.70.0000.00717.49
8.1.60.0030.00617.62
8.1.50.0040.00417.50
8.1.40.0080.00017.66
8.1.30.0040.00417.53
8.1.20.0050.00317.70
8.1.10.0000.00717.64
8.1.00.0000.00817.54
8.0.300.0000.00820.00
8.0.290.0040.00416.88
8.0.280.0070.00018.57
8.0.270.0030.00317.33
8.0.260.0050.00316.91
8.0.250.0040.00417.13
8.0.240.0000.00917.04
8.0.230.0030.00317.06
8.0.220.0000.00716.98
8.0.210.0050.00216.89
8.0.200.0040.00416.98
8.0.190.0000.00717.07
8.0.180.0040.00416.92
8.0.170.0080.00016.96
8.0.160.0030.00617.05
8.0.150.0040.00416.86
8.0.140.0000.00816.97
8.0.130.0030.00313.48
8.0.120.0070.00016.95
8.0.110.0040.00416.84
8.0.100.0000.00717.05
8.0.90.0040.00417.01
8.0.80.0060.01216.94
8.0.70.0040.00417.09
8.0.60.0050.00317.07
8.0.50.0000.00716.92
8.0.30.0120.00617.40
8.0.20.0060.01316.88
8.0.10.0070.00017.07
8.0.00.0070.01216.88
7.4.330.0000.00513.11
7.4.320.0030.00316.52
7.4.300.0000.00716.60
7.4.290.0000.00716.65
7.4.280.0000.00716.57
7.4.270.0070.00016.48
7.4.260.0050.00013.43
7.4.250.0050.00516.63
7.4.240.0070.00016.55
7.4.230.0040.00416.67
7.4.220.0100.01016.59
7.4.210.0090.01016.59
7.4.200.0070.00016.74
7.4.190.0060.00316.70
7.4.160.0060.01016.51
7.4.150.0090.00916.41
7.4.140.0100.00716.57
7.4.130.0080.01116.66
7.4.120.0070.01316.45
7.4.110.0060.01216.65
7.4.100.0130.01016.56
7.4.90.0110.00816.63
7.4.80.0100.01319.39
7.4.70.0070.01016.61
7.4.60.0140.00316.63
7.4.50.0040.00416.33
7.4.40.0090.00616.61
7.4.30.0080.00816.84
7.4.00.0070.01014.95
7.3.330.0050.00213.46
7.3.320.0000.00513.46
7.3.310.0030.00516.50
7.3.300.0030.00316.33
7.3.290.0090.00516.40
7.3.280.0040.01716.43
7.3.270.0100.00716.61
7.3.260.0070.01416.51
7.3.250.0090.00916.47
7.3.240.0070.01016.70
7.3.230.0100.00716.40
7.3.210.0210.00316.54
7.3.200.0130.00616.42
7.3.190.0110.00616.47
7.3.180.0080.00816.67
7.3.170.0080.00816.44
7.3.160.0080.00816.44
7.3.120.0050.01315.05
7.3.110.0040.01515.14
7.3.100.0080.00314.78
7.3.90.0060.01014.98
7.3.80.0060.01214.66
7.3.70.0090.00314.86
7.3.60.0070.00714.99
7.3.50.0040.01114.77
7.3.40.0050.00514.96
7.3.30.0090.00614.91
7.3.20.0100.00716.43
7.3.10.0030.01216.46
7.3.00.0030.01116.49
7.2.330.0130.00916.53
7.2.320.0090.01516.74
7.2.310.0150.00616.84
7.2.300.0120.00916.73
7.2.290.0090.00916.77
7.2.250.0130.00614.88
7.2.240.0040.01515.30
7.2.230.0030.01315.07
7.2.220.0080.00415.15
7.2.210.0070.01015.28
7.2.200.0100.01014.97
7.2.190.0070.01114.88
7.2.180.0040.01114.79
7.2.170.0090.00614.82
7.2.130.0030.01016.41
7.2.120.0030.01316.47
7.2.110.0070.00716.65
7.2.100.0040.00816.33
7.2.90.0040.00716.72
7.2.80.0030.01616.80
7.2.70.0110.00216.70
7.2.60.0080.00616.65
7.2.50.0060.00816.76
7.2.40.0040.00716.66
7.2.30.0070.00416.70
7.2.20.0000.01416.75
7.2.10.0050.01016.68
7.2.00.0030.00616.98
7.1.330.0030.01015.42
7.1.320.0060.00315.67
7.1.310.0090.00915.77
7.1.300.0100.00315.82
7.1.290.0030.01015.86
7.1.280.0060.01315.83
7.1.270.0110.00715.73
7.1.260.0040.00715.53
7.1.250.0080.00015.64
7.1.200.0090.00315.73
7.1.100.0030.01317.93
7.1.70.0120.00817.07
7.1.60.0100.01419.31
7.1.50.0000.02116.66
7.1.00.0030.07722.41
7.0.200.0360.00314.75
7.0.140.0030.07022.19
7.0.120.0000.07722.18
7.0.60.0100.05019.80
7.0.50.0070.09017.89
7.0.40.0030.04320.20
7.0.30.0230.07320.24
7.0.20.0270.05720.33
7.0.10.0030.08320.15
7.0.00.0000.04720.22
5.6.280.0000.07720.83
5.6.210.0130.06720.67
5.6.200.0270.05018.25
5.6.190.0000.05720.52
5.6.180.0330.07320.39
5.6.170.0330.05320.54
5.6.160.0070.07020.71
5.6.150.0100.07718.15
5.6.140.0130.07018.18
5.6.130.0030.08718.15
5.6.120.0100.08021.06
5.6.110.0100.08720.90
5.6.100.0070.09021.12
5.6.90.0130.06720.98
5.6.80.0030.04320.40
5.5.350.0300.07020.44
5.5.340.0100.06317.99
5.5.330.0030.04720.29
5.5.320.0200.05020.31
5.5.310.0230.06320.36
5.5.300.0070.05718.04
5.5.290.0000.06018.04
5.5.280.0200.07320.98
5.5.270.0130.06720.66
5.5.260.0000.05020.74
5.5.250.0100.07320.79
5.5.240.3000.04320.27
5.4.450.0030.08319.53
5.4.440.0070.06719.57
5.4.430.0030.08719.18
5.4.420.0100.06719.19
5.4.410.0130.05319.20
5.4.400.0030.04019.01
5.4.390.0030.04319.08
5.4.380.0030.04719.08
5.4.370.0070.07719.24
5.4.360.0070.07718.85
5.4.350.0000.04718.85
5.4.340.0030.07318.93
5.4.320.0030.06019.25
5.4.310.0070.07719.25
5.4.300.0070.07319.14
5.4.290.0000.06019.24
5.4.280.0000.08319.11
5.4.270.0070.04319.07
5.4.260.0100.04319.16
5.4.250.0030.05019.15
5.4.240.0170.07318.97
5.4.230.0030.06719.14
5.4.220.0100.07718.87
5.4.210.0030.07718.86
5.4.200.0100.03718.91
5.4.190.0070.03719.04
5.4.180.0100.05319.21
5.4.170.0070.03718.86
5.4.160.0070.04319.19
5.4.150.0100.06019.19
5.4.140.0070.04016.42
5.4.130.0070.05316.32
5.4.120.0100.07316.54
5.4.110.0100.03316.44
5.4.100.0200.04316.34
5.4.90.0100.07016.43
5.4.80.0170.05316.38
5.4.70.0070.06716.41
5.4.60.0070.04716.64
5.4.50.0030.05316.50
5.4.40.0000.04016.38
5.4.30.0130.06016.30
5.4.20.0000.04316.35
5.4.10.0030.04016.36
5.4.00.0000.03715.86
5.3.290.0130.07314.73
5.3.280.0030.05314.67
5.3.270.0030.04014.61
5.3.260.0030.03714.68
5.3.250.0000.04014.66
5.3.240.0070.05014.64
5.3.230.0000.04714.60
5.3.220.0070.06014.61
5.3.210.0130.03714.62
5.3.200.0000.07714.63
5.3.190.0030.04314.46
5.3.180.0000.04314.57
5.3.170.0130.06014.71
5.3.160.0030.07714.73
5.3.150.0070.04714.58
5.3.140.0070.03314.48
5.3.130.0070.03314.55
5.3.120.0000.04014.55
5.3.110.0000.04314.44
5.3.100.0000.04014.07
5.3.90.0030.04314.04
5.3.80.0030.03713.98
5.3.70.0030.03713.91
5.3.60.0030.03314.00
5.3.50.0000.03714.10
5.3.40.0000.03713.90
5.3.30.0000.03713.82
5.3.20.0030.04013.70
5.3.10.0030.03313.62
5.3.00.0030.03313.70
5.2.170.0000.03011.22
5.2.160.0000.03011.15
5.2.150.0000.03011.29
5.2.140.0000.03011.09
5.2.130.0000.03011.07
5.2.120.0030.02711.07
5.2.110.0000.03010.99
5.2.100.0000.03011.16
5.2.90.0030.02711.12
5.2.80.0000.03011.10
5.2.70.0000.04011.17
5.2.60.0030.02711.09
5.2.50.0000.03311.02
5.2.40.0030.02711.16
5.2.30.0000.03011.12
5.2.20.0100.02011.03
5.2.10.0030.02711.01
5.2.00.0000.03010.71
5.1.60.0000.02310.00
5.1.50.0030.02710.04
5.1.40.0070.0209.97
5.1.30.0000.02710.23
5.1.20.0030.02310.36
5.1.10.0000.02710.09
5.1.00.0030.02710.18
5.0.50.0000.0208.50
5.0.40.0070.0138.42
5.0.30.0000.0378.19
5.0.20.0000.0208.23
5.0.10.0000.0208.24
5.0.00.0000.0308.21
4.4.90.0000.0177.73
4.4.80.0000.0177.73
4.4.70.0030.0137.73
4.4.60.0000.0177.73
4.4.50.0030.0137.73
4.4.40.0030.0207.73
4.4.30.0000.0177.73
4.4.20.0030.0137.73
4.4.10.0030.0137.73
4.4.00.0000.0307.73
4.3.110.0030.0137.73
4.3.100.0030.0137.73
4.3.90.0000.0137.73
4.3.80.0000.0237.73
4.3.70.0030.0207.73
4.3.60.0000.0137.73
4.3.50.0000.0177.73
4.3.40.0000.0237.73
4.3.30.0000.0177.73
4.3.20.0000.0177.73
4.3.10.0000.0177.73
4.3.00.0000.0177.73

preferences:
44.66 ms | 401 KiB | 5 Q