3v4l.org

run code in 300+ PHP versions simultaneously
<?php function FormatSql($query, array $params = []) { $patt = '~ ([\'"`]) # capture this quote character (?:\\\\.|(?!\1).)* # any escaped character, or # any character that isn\'t the captured one \1 # the captured quote again (*SKIP)(*FAIL) # ignore this | \?\?? # one or two question marks | ::?\w+ # word characters marked with one or two colons~x'; return preg_replace_callback($patt, function ($matches) use (&$params) { if(!isset($matches[1])) return $matches[0]; switch($matches[1]) { case '?': if(!$params) throw new \DomainException("Not enough params"); return '*snip*'; case '??': if(!$params) throw new \DomainException("Not enough params"); return '*snip*'; case ':': if(!array_key_exists($matches[2], $params)) throw new \DomainException("\"$matches[2]\" param not provided"); return '*snip*'; case '::': if(!array_key_exists($matches[2], $params)) throw new \DomainException("\"$matches[2]\" param not provided"); return '*snip*'; } throw new \Exception("Bad regex"); }, $query); } $bigStr = str_repeat('x', 443000); $bigQuery = "INSERT INTO `emr_doc_file` (`emr_doc_id`, `edf_file`, `edf_mimetype`, `edf_upload_date`) VALUES ('108', x'$bigStr', 'application/pdf', 1490978009)"; $result = FormatSql($bigQuery, []); if($result === null) { throw new \Exception("preg error: " . preg_last_error() . "\nsee: http://php.net/manual/en/pcre.constants.php#117743"); } echo substr($result,0,100).PHP_EOL;

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.4.130.0120.00619.11
8.4.120.0130.00822.22
8.4.110.0150.00719.72
8.4.100.0100.00319.22
8.4.90.0150.00818.82
8.4.80.0090.00319.10
8.4.70.0160.00819.17
8.4.60.0130.00919.81
8.4.50.0110.01219.40
8.4.40.0100.01019.77
8.4.30.0060.01020.25
8.4.20.0140.00722.14
8.4.10.0040.00818.98
8.3.260.0120.00818.13
8.3.250.0110.00919.83
8.3.240.0060.00418.01
8.3.230.0140.00817.86
8.3.220.0120.00918.09
8.3.210.0040.00518.02
8.3.200.0150.00518.01
8.3.190.0130.01018.13
8.3.180.0080.00717.87
8.3.170.0150.00618.35
8.3.160.0090.00018.29
8.3.150.0070.01317.91
8.3.140.0120.00218.89
8.3.130.0040.00418.98
8.3.120.0060.00320.16
8.3.110.0060.00320.94
8.3.100.0000.00917.80
8.3.90.0150.00726.77
8.3.80.0060.00317.79
8.3.70.0150.00618.93
8.3.60.0100.00617.88
8.3.50.0110.01121.77
8.3.40.0130.00320.16
8.3.30.0160.00019.95
8.3.20.0060.00321.52
8.3.10.0000.00923.02
8.3.00.0060.00322.85
8.2.290.0120.00921.46
8.2.280.0090.00219.63
8.2.270.0170.00317.76
8.2.260.0060.00317.88
8.2.250.0100.01018.94
8.2.240.0090.00017.98
8.2.230.0030.00622.58
8.2.220.0060.00324.06
8.2.210.0030.00626.77
8.2.200.0090.00018.00
8.2.190.0100.01318.13
8.2.180.0070.01025.92
8.2.170.0070.01020.20
8.2.160.0110.00422.96
8.2.150.0000.00925.66
8.2.140.0060.00924.66
8.2.130.0000.00822.27
8.2.120.0000.00926.35
8.2.110.0030.00621.43
8.2.100.0060.00619.03
8.2.90.0040.00420.46
8.2.80.0000.00821.67
8.2.70.0080.00018.88
8.2.60.0040.00418.93
8.2.50.0030.00618.87
8.2.40.0000.00821.54
8.2.30.0000.00820.32
8.2.20.0050.00319.10
8.2.10.0040.00419.15
8.2.00.0030.00519.33
8.1.330.0100.01019.57
8.1.320.0120.00817.88
8.1.310.0090.00017.36
8.1.300.0060.00319.68
8.1.290.0070.00330.84
8.1.280.0130.01025.92
8.1.270.0050.00324.12
8.1.260.0080.00026.35
8.1.250.0030.00628.09
8.1.240.0000.00923.25
8.1.230.0080.00422.91
8.1.220.0030.00618.89
8.1.210.0000.00820.16
8.1.200.0070.00218.59
8.1.190.0040.00418.60
8.1.180.0000.00918.66
8.1.170.0040.00419.89
8.1.160.0000.00820.15
8.1.150.0000.00821.40
8.1.140.0050.00320.71
8.1.130.0000.00720.16
8.1.120.0040.00418.77
8.1.110.0060.00318.61
8.1.100.0060.00318.79
8.1.90.0080.00018.65
8.1.80.0030.00518.66
8.1.70.0000.00818.73
8.1.60.0030.00618.87
8.1.50.0030.00518.82
8.1.40.0070.00418.71
8.1.30.0000.00818.80
8.1.20.0030.00518.80
8.1.10.0080.00018.75
8.1.00.0080.00018.67
8.0.300.0000.00821.13
8.0.290.0000.00818.13
8.0.280.0070.00019.52
8.0.270.0000.00818.40
8.0.260.0030.00318.25
8.0.250.0040.00418.28
8.0.240.0090.00018.11
8.0.230.0000.00818.28
8.0.220.0000.00718.18
8.0.210.0000.00718.26
8.0.200.0000.00718.27
8.0.190.0060.00618.29
8.0.180.0060.00318.25
8.0.170.0000.00818.22
8.0.160.0000.00818.18
8.0.150.0030.00618.16
8.0.140.0030.00618.17
8.0.130.0000.00614.68
8.0.120.0040.00418.14
8.0.110.0060.00318.11
8.0.100.0000.00818.05
8.0.90.0050.00318.00
8.0.80.0130.00618.14
8.0.70.0050.00318.17
8.0.60.0040.00418.21
8.0.50.0050.00318.29
8.0.30.0110.01118.36
8.0.20.0110.01218.34
8.0.10.0000.00818.25
8.0.00.0040.01617.84
7.4.330.0040.00415.55
7.4.320.0040.00417.81
7.4.300.0000.00717.83
7.4.290.0050.00517.91
7.4.280.0030.00617.81
7.4.270.0080.00017.97
7.4.260.0040.00417.93
7.4.250.0000.00717.89
7.4.240.0000.00817.73
7.4.230.0030.00517.75
7.4.220.0110.01817.99
7.4.210.0090.01317.89
7.4.200.0000.00818.09
7.4.160.0070.01217.89
7.4.150.0160.00317.79
7.4.140.0140.00817.92
7.4.130.0080.01217.90
7.4.120.0120.01117.76
7.4.110.0120.01417.85
7.4.100.0130.01317.95
7.4.90.0090.00917.84
7.4.80.0030.01619.39
7.4.70.0120.00617.82
7.4.60.0090.01017.93
7.4.50.0100.00617.76
7.4.40.0000.01817.68
7.4.30.0120.00617.80
7.4.00.0050.01216.38
7.3.330.0030.00314.48
7.3.320.0030.00314.59
7.3.310.0030.00617.67
7.3.300.0000.00717.54
7.3.290.0090.01017.64
7.3.280.0100.00917.64
7.3.270.0430.01017.80
7.3.260.0160.00317.71
7.3.250.0100.01017.70
7.3.240.0100.01017.70
7.3.230.0110.00917.67
7.3.210.0150.00317.62
7.3.200.0150.00317.62
7.3.190.0060.01217.67
7.3.180.0140.01017.76
7.3.170.0030.01517.91
7.3.160.0100.01017.72
7.3.120.0110.00716.20
7.3.110.0120.00916.00
7.3.100.0030.00916.06
7.3.90.0000.01216.20
7.3.80.0090.00016.06
7.3.70.0070.00716.20
7.3.60.0070.00716.21
7.3.50.0100.00016.26
7.3.40.0030.01316.26
7.3.30.0100.00315.86
7.3.20.0070.00717.14
7.3.10.0070.00916.96
7.3.00.0070.00616.95
7.2.330.0150.00617.83
7.2.320.0090.00917.73
7.2.310.0130.00617.73
7.2.300.0110.00817.84
7.2.290.0070.01217.71
7.2.250.0070.01316.10
7.2.240.0070.01416.04
7.2.230.0080.00816.34
7.2.220.0000.01316.13
7.2.210.0100.00016.31
7.2.200.0110.00716.23
7.2.190.0090.00916.20
7.2.180.0000.01216.29
7.2.170.0040.01616.27
7.2.130.0130.00416.92
7.2.120.0080.00716.96
7.2.110.0080.00817.09
7.2.100.0090.00817.09
7.2.90.0060.00917.09
7.2.80.0100.00716.96
7.2.70.0070.00817.08
7.2.60.0080.01116.96
7.2.50.0120.00417.15
7.2.40.0150.00516.98
7.2.30.0110.01016.92
7.2.20.0090.01316.98
7.2.10.0070.01117.07
7.2.00.0080.01117.22
7.1.330.0060.00715.98
7.1.320.0080.00415.75
7.1.310.0030.00715.89
7.1.300.0060.00615.82
7.1.290.0030.00916.04
7.1.280.0000.00915.96
7.1.270.0100.00016.16
7.1.260.0040.01115.88
7.1.250.0040.01115.83
7.1.200.0030.00716.08
7.1.70.0030.00617.55
7.1.60.0100.00017.57
7.1.50.0150.00917.04
7.1.30.3170.06037.33
7.1.20.3530.07037.31
7.1.10.2830.06721.32
7.1.00.2970.06321.52
7.0.200.0040.00417.08
7.0.170.3470.06321.00
7.0.160.3570.05021.00
7.0.150.3230.08321.00
7.0.140.2730.05720.98
7.0.130.3370.06720.98
7.0.120.2970.06720.81
7.0.110.3730.08020.90
7.0.100.3230.06021.05
7.0.90.3370.06321.04
7.0.80.3200.05320.90
7.0.70.2230.06320.90
7.0.60.3830.07020.85
7.0.50.3100.06720.80
7.0.40.3030.06020.89
7.0.30.2700.05720.96
7.0.20.3270.09720.89
7.0.10.3070.08320.90
7.0.00.3930.06020.86

preferences:
28.2 ms | 403 KiB | 5 Q