3v4l.org

run code in 300+ PHP versions simultaneously
<?php // -- PULLING IN PRODUCTS TO READ OUT TO USER -- // $stmt = (" SELECT products.ID, products.title, products.category, products.location, products.price, products.negotiable, products.description, products.photo, products.user_id FROM products"); $result = $db->query($stmt); foreach ($result as $row) { $product_id = $row['ID']; $title = htmlspecialchars($row['title'], ENT_QUOTES); // User input, prevent first order XSS $category = $row['category']; // local variable for remainder, ensuring to use htmlspecialchars() for any user input that will be read out to browser } // -- INSERTING ONE PRODUCT TO MAIN PRODUCT PAGE USING PREPARED STATEMENT -- // // Incoming user input from some form // Assign input to local variables // Probably should validate data $null_value = null; // To bind null values... I'm lazy $stmt = $db->prepare(" INSERT INTO products VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->bind_param('sssssssss', $null_value, $title, $category, $location, $price, $negotiable, $description, $photo, $user_id); $stmt->execute(); // -- INSERTING MULTIPLE PRODUCTS TO MAIN PRODUCT PAGE USING PREPARED STATEMENT -- // // Incoming user input from some form $null_value = null; // To bind null values... I'm lazy // Assuming user input is from a form // Verify it is a form submission if($_SERVER['REQUEST_METHOD'] === 'POST') { foreach ($_POST['product_array'] as $product) { foreach ($product as $row) { // Validate data types // Assign to to local variables $stmt = $db->prepare(" INSERT INTO products VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->bind_param('sssssssss', $null_value, $title, $category, $location, $price, $negotiable, $description, $photo, $user_id); $stmt->execute(); } } }

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.0070.01418.55
8.3.60.0100.00716.75
8.3.50.0170.00317.96
8.3.40.0100.00720.23
8.3.30.0140.00318.84
8.3.20.0080.00024.18
8.3.10.0000.00724.66
8.3.00.0070.00326.16
8.2.190.0090.00918.54
8.2.180.0120.00925.92
8.2.170.0140.00718.83
8.2.160.0070.00722.96
8.2.150.0000.00825.66
8.2.140.0080.00624.66
8.2.130.0070.00026.16
8.2.120.0060.00319.27
8.2.110.0060.00319.33
8.2.100.0080.00417.84
8.2.90.0080.00017.75
8.2.80.0040.00418.96
8.2.70.0080.00017.63
8.2.60.0050.00317.38
8.2.50.0030.00518.05
8.2.40.0020.00518.03
8.2.30.0020.00517.88
8.2.20.0070.00018.11
8.2.10.0040.00420.98
8.2.00.0040.00419.25
8.1.280.0110.00425.92
8.1.270.0040.00424.02
8.1.260.0000.00826.35
8.1.250.0070.00028.09
8.1.240.0060.00322.19
8.1.230.0060.00621.04
8.1.220.0050.00318.75
8.1.210.0030.00518.77
8.1.200.0000.00817.53
8.1.190.0080.00017.35
8.1.180.0090.00018.10
8.1.170.0000.00718.96
8.1.160.0000.00718.84
8.1.150.0030.00518.76
8.1.140.0000.00718.84
8.1.130.0030.00319.96
8.1.120.0070.00317.44
8.1.110.0050.00317.42
8.1.100.0070.00017.45
8.1.90.0050.00317.45
8.1.80.0000.00817.41
8.1.70.0030.00317.29
8.1.60.0040.00417.49
8.1.50.0040.00417.56
8.1.40.0040.00417.44
8.1.30.0040.00417.63
8.1.20.0040.00417.66
8.1.10.0090.00017.58
8.1.00.0030.00617.58
8.0.300.0080.00018.77
8.0.290.0020.00516.63
8.0.280.0070.00018.32
8.0.270.0030.00317.93
8.0.260.0030.00318.43
8.0.250.0000.00617.00
8.0.240.0030.00617.02
8.0.230.0070.00016.90
8.0.220.0040.00416.87
8.0.210.0030.00316.81
8.0.200.0060.00016.92
8.0.190.0000.00717.00
8.0.180.0050.00216.82
8.0.170.0080.00016.81
8.0.160.0000.00716.91
8.0.150.0000.00816.86
8.0.140.0000.00716.74
8.0.130.0000.00613.30
8.0.120.0040.00416.84
8.0.110.0040.00417.02
8.0.100.0000.00816.92
8.0.90.0000.00716.97
8.0.80.0120.00316.80
8.0.70.0030.00516.95
8.0.60.0080.00016.96
8.0.50.0000.00916.92
8.0.30.0030.01817.23
8.0.20.0120.01016.97
8.0.10.0000.00817.05
8.0.00.0130.01016.98
7.4.330.0000.00515.55
7.4.320.0000.00616.56
7.4.300.0060.00016.52
7.4.290.0040.00416.63
7.4.280.0070.00016.36
7.4.270.0000.00716.52
7.4.260.0050.00013.30
7.4.250.0030.00516.38
7.4.240.0000.00716.52
7.4.230.0050.00316.55
7.4.220.0040.00316.36
7.4.210.0090.00416.56
7.4.200.0030.00516.45
7.4.130.0090.00916.49
7.4.120.0130.01016.58
7.4.110.0070.01016.53
7.4.100.0140.00416.50
7.4.90.0100.01016.12
7.4.80.0090.00916.37
7.4.70.0120.00616.42
7.4.60.0170.00316.21
7.4.50.0120.00616.16
7.4.40.0070.01116.55
7.4.30.0170.00316.42
7.4.20.0150.00316.33
7.4.10.0050.01416.32
7.4.00.0100.00716.35
7.3.330.0000.00716.20
7.3.320.0030.00313.03
7.3.310.0000.00716.21
7.3.300.0000.00716.29
7.3.290.0070.00916.29
7.3.260.0110.00716.23
7.3.230.0060.01316.20
7.3.220.0170.00016.17
7.3.210.0140.00316.48
7.3.200.0100.01016.23
7.3.190.0120.00616.28
7.3.180.0180.00316.32
7.3.170.0170.00016.35
7.3.160.0140.00716.39
7.3.150.0090.00816.29
7.3.140.0120.00616.42
7.3.130.0120.00616.12
7.3.120.0110.00616.11
7.3.110.0080.00816.38
7.3.100.0110.00516.13
7.3.90.0100.00716.19
7.3.80.0130.01016.15
7.3.70.0100.00716.37
7.3.60.0070.01016.27
7.3.50.0110.00616.38
7.3.40.0100.00716.22
7.3.30.0090.01216.16
7.3.20.0290.00316.21
7.3.10.0000.01716.09
7.3.00.0100.00716.11
7.2.330.0090.00916.51
7.2.320.0120.00616.41
7.2.310.0060.01316.37
7.2.300.0180.00016.14
7.2.290.0090.00916.24
7.2.280.0090.00916.73
7.2.270.0100.00916.31
7.2.260.0110.01116.28
7.2.250.0140.00416.28
7.2.240.0070.01016.16
7.2.230.0030.01416.34
7.2.220.0090.00916.15
7.2.210.0130.00316.28
7.2.200.0110.00716.28
7.2.190.0090.01516.09
7.2.180.0100.00716.27
7.2.170.0110.00816.20
7.2.160.0150.00916.26
7.2.150.0300.01616.14
7.2.140.0030.01616.18
7.2.130.0100.01016.26
7.2.120.0110.00716.39
7.2.110.0090.00916.17
7.2.100.0070.01116.48
7.2.90.0090.00916.38
7.2.80.0090.00916.23
7.2.70.0100.00716.44
7.2.60.0180.00016.34
7.2.50.0090.00916.36
7.2.40.0090.00916.38
7.2.30.0110.00716.50
7.2.20.0110.00716.34
7.2.10.0130.00616.43
7.2.00.0120.00616.38

preferences:
66.74 ms | 400 KiB | 5 Q