3v4l.org

run code in 300+ PHP versions simultaneously
<?php //-------------------------------------------------- // Just while the function is re-named if (!function_exists('is_trusted')) { function is_trusted($value) { return is_literal($value); } } //-------------------------------------------------- $limit = trim(' 100 '); // Not trusted $_GET['ids'] = [trim(' 1 '), 2, 3]; var_dump($_GET['ids'][0], is_trusted($_GET['ids'][0])); $ids_untrusted = ( $_GET['ids'] ?? [] ); $ids_trusted = array_map( 'intval', $ids_untrusted ); //-------------------------------------------------- $sql = 'SELECT * FROM foo WHERE id IN (' . implode( ',', $ids_untrusted ) . ')'; // Whoops var_dump($sql, is_trusted($sql)); //-------------------------------------------------- $sql = 'SELECT * FROM foo WHERE id IN (' . implode( ',', $ids_trusted ) . ')'; var_dump($sql, is_trusted($sql)); //-------------------------------------------------- $sql = sprintf( 'SELECT * FROM foo WHERE id IN (%s)', implode( ',', $ids_trusted ) ); var_dump($sql, is_trusted($sql)); //-------------------------------------------------- $sql = sprintf( 'SELECT * FROM foo LIMIT %d', (int)$limit ); var_dump($sql, is_trusted($sql)); ?>

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.01118.55
8.3.50.0110.00417.98
8.3.40.0150.00718.75
8.3.30.0080.00819.00
8.3.20.0000.00824.18
8.3.10.0070.00024.66
8.3.00.0040.00426.16
8.2.180.0140.00725.92
8.2.170.0120.00322.96
8.2.160.0080.00622.96
8.2.150.0090.00025.66
8.2.140.0000.00824.66
8.2.130.0000.00726.16
8.2.120.0000.00819.48
8.2.110.0000.00920.39
8.2.100.0000.01020.52
8.1.280.0130.00725.92
8.1.270.0040.00423.99
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0000.00920.90
8.1.230.0100.00019.00

preferences:
50.85 ms | 400 KiB | 5 Q