3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * 安全地执行SQL语句. * * 该函数会将所有参数经过安全地转义, 用来替换SQL命令中的占位符, 最后送至服务器进行执行. * * 占位符是 %s , 如果需要在SQL命令中包含百分号, 请连写两个百分号. * * @param resource $conn 由 mysql_connect() 建立的MySQL数据库连接资源 * @param string $sql SQL语句, 可以包含占位符 * @param mixed $more... 用来替换占位符的参数 * * @return resource 该函数会返回 mysql_query() 的返回值. */ function safeSQL($conn,$sql,$more=NULL) { $args=func_get_args(); array_shift($args); array_shift($args); $offset=0; foreach($args as $i) { if(preg_match("/%([tT])/",$sql,$result,PREG_OFFSET_CAPTURE,$offset)) { $fStr=$result[1][0]; $pos=$result[1][1]; $tPos=$pos-1; while($sql[$pos]=="%") $tPos--; if(!(($pos-$tPos)%2)) continue; $value=mysql_real_escape_string($value,$conn); $sql=substr($sql,0,$pos-1) . $value . substr($sql,$pos+1); $offset=$pos + 1; } } $sql=str_replace("%%", "%", $sql); echo $sql."\n"; } safeSQL(0,"SELECT * FROM `user`"); safeSQL(0,"SELECT * FROM `user` WHERE `uname`='%s'","jybox"); safeSQL(0,"UPDATE `%s` SET `email`='%t' WHERE `uname`='%s'","user","m@jybox.net","jybox"); safeSQL(0,"SELECT * FROM `user` WHERE `uname` LIKE ='%%%s%%'","jybox"); safeSQL(0,"SELECT * FROM `user`");

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.0180.00318.85
8.3.50.0140.00322.11
8.3.40.0090.00619.12
8.3.30.0190.00019.09
8.3.20.0040.00419.24
8.3.10.0090.00021.27
8.3.00.0070.00021.88
8.2.180.0120.00316.88
8.2.170.0110.00422.96
8.2.160.0070.00721.16
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00421.17
8.2.110.0100.00019.29
8.2.100.0030.00918.09
8.2.90.0030.00619.39
8.2.80.0060.00318.00
8.2.70.0060.00317.88
8.2.60.0030.00517.80
8.2.50.0040.00418.07
8.2.40.0040.00418.34
8.2.30.0000.00721.29
8.2.20.0040.00418.00
8.2.10.0030.00518.14
8.2.00.0030.00518.00
8.1.280.0070.00725.92
8.1.270.0000.00823.99
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0070.00322.58
8.1.230.0110.00021.10
8.1.220.0040.00418.77
8.1.210.0100.00019.04
8.1.200.0070.00317.73
8.1.190.0030.00517.64
8.1.180.0060.00318.10
8.1.170.0000.00818.90
8.1.160.0040.00418.93
8.1.150.0040.00418.85
8.1.140.0000.00817.70
8.1.130.0000.00717.88
8.1.120.0070.00017.52
8.1.110.0050.00317.54
8.1.100.0050.00217.66
8.1.90.0000.00717.57
8.1.80.0000.00717.70
8.1.70.0080.00017.64
8.1.60.0000.00817.77
8.1.50.0000.00717.65
8.1.40.0080.00017.75
8.1.30.0080.00017.85
8.1.20.0000.00817.81
8.1.10.0040.00417.72
8.1.00.0060.00317.68
8.0.300.0030.00620.10
8.0.290.0040.00417.18
8.0.280.0040.00418.43
8.0.270.0040.00417.37
8.0.260.0000.00717.14
8.0.250.0040.00417.23
8.0.240.0030.00617.19
8.0.230.0000.01017.07
8.0.220.0030.00517.20
8.0.210.0000.00717.20
8.0.200.0040.00417.25
8.0.190.0000.00717.25
8.0.180.0070.00017.11
8.0.170.0030.00517.07
8.0.160.0000.00717.20
8.0.150.0000.00717.10
8.0.140.0030.00517.13
8.0.130.0030.00313.53
8.0.120.0040.00417.25
8.0.110.0030.00517.04
8.0.100.0000.00717.27
8.0.90.0040.00417.18
8.0.80.0040.01117.16
8.0.70.0040.00417.09
8.0.60.0040.00417.27
8.0.50.0030.00517.15
8.0.30.0110.01117.42
8.0.20.0090.00917.51
8.0.10.0060.00317.37
8.0.00.0150.00317.08
7.4.330.0060.00014.96
7.4.320.0070.00316.83
7.4.300.0040.00416.95
7.4.290.0030.00316.68
7.4.280.0000.00716.89
7.4.270.0070.00016.77
7.4.260.0060.00013.60
7.4.250.0070.00016.74
7.4.240.0030.00316.80
7.4.230.0000.00716.66
7.4.220.0060.00916.96
7.4.210.0050.01216.86
7.4.200.0000.00716.95
7.4.190.0000.00816.82
7.4.160.0130.00316.58
7.4.150.0090.00917.40
7.4.140.0110.01317.86
7.4.130.0140.00616.80
7.4.120.0150.00216.75
7.4.110.0100.00716.78
7.4.100.0060.01216.87
7.4.90.0060.01216.72
7.4.80.0070.01019.39
7.4.70.0040.01416.94
7.4.60.0030.01816.79
7.4.50.0000.01016.58
7.4.40.0090.00622.77
7.4.30.0050.01316.66
7.4.00.0070.01015.19
7.3.330.0050.00013.46
7.3.320.0050.00213.57
7.3.310.0030.00316.66
7.3.300.0040.00416.51
7.3.290.0040.01616.54
7.3.280.0080.00916.62
7.3.270.0060.01217.40
7.3.260.0100.01118.24
7.3.250.0070.01216.78
7.3.240.0100.00616.85
7.3.230.0090.00916.61
7.3.210.0070.01116.73
7.3.200.0120.01019.39
7.3.190.0130.01016.75
7.3.180.0100.00716.76
7.3.170.0030.01316.50
7.3.160.0070.01716.75
7.3.120.0030.01015.02
7.3.10.0070.00916.68
7.3.00.0080.00416.81
7.2.330.0150.00416.91
7.2.320.0120.00616.73
7.2.310.0130.01016.95
7.2.300.0090.00816.77
7.2.290.0060.01216.77
7.2.130.0080.00717.09
7.2.120.0110.00217.04
7.2.110.0070.00516.87
7.2.100.0050.00916.98
7.2.90.0110.00617.06
7.2.80.0020.01416.96
7.2.70.0090.00817.17
7.2.60.0090.00317.15
7.2.50.0070.00816.95
7.2.40.0140.00316.93
7.2.30.0140.00317.02
7.2.20.0080.01017.19
7.2.10.0070.00916.97
7.2.00.0070.01017.84
7.1.250.0090.00615.83
7.1.200.0120.00315.98
7.1.100.0060.00318.29
7.1.70.0000.00817.30
7.1.60.0060.01919.40
7.1.50.0000.02017.12
7.1.00.0070.03022.53
7.0.200.0000.00816.90
7.0.140.0000.07322.21
7.0.70.0100.08021.76
7.0.60.0130.07321.83
7.0.50.0030.05722.09
7.0.40.0000.04720.12
7.0.30.0100.07720.10
7.0.20.0000.06320.13
7.0.10.0030.06020.08
7.0.00.0030.04020.03
5.6.280.0070.07020.92
5.6.220.0000.06720.54
5.6.210.0100.06320.57
5.6.200.0030.05720.96
5.6.190.0070.04021.18
5.6.180.0070.07021.04
5.6.170.0000.08021.09
5.6.160.0000.06721.13
5.6.150.0030.05721.05
5.6.140.0030.06321.04
5.6.130.0070.08021.07
5.6.120.0030.04321.00
5.6.110.0000.07321.12
5.6.100.0030.05321.09
5.6.90.0030.08321.08
5.6.80.0130.06720.48
5.6.70.0000.05020.41
5.6.60.0030.05320.49
5.6.50.0030.05320.45
5.6.40.0030.07720.45
5.6.30.0030.08320.32
5.6.20.0030.08020.31
5.6.10.0070.07720.43
5.6.00.0000.07320.29
5.5.360.0070.08020.35
5.5.350.0070.07320.43
5.5.340.0070.08020.75
5.5.330.0000.06020.77
5.5.320.0100.04320.63
5.5.310.0070.05720.94
5.5.300.0000.08320.84
5.5.290.0130.07720.84
5.5.280.0030.05320.91
5.5.270.0100.08020.84
5.5.260.0030.04020.88
5.5.250.0070.03720.57
5.5.240.0000.08020.28
5.5.230.0030.08320.19
5.5.220.0000.05720.32
5.5.210.0030.04720.18
5.5.200.0070.07320.00
5.5.190.0100.07720.25
5.5.180.0000.06320.27
5.5.160.0070.05720.01
5.5.150.0030.04720.13
5.5.140.0000.04320.20
5.5.130.0100.06720.11
5.5.120.0100.07320.11
5.5.110.0030.08020.16
5.5.100.0030.07720.06
5.5.90.0000.07319.97
5.5.80.0000.04320.07
5.5.70.0070.07020.06
5.5.60.0070.07720.15
5.5.50.0030.03720.11
5.5.40.0070.03320.09
5.5.30.0030.04720.05
5.5.20.0030.04020.08
5.5.10.0070.07720.04
5.5.00.0100.07020.13
5.4.450.0070.06319.42
5.4.440.0100.07319.54
5.4.430.0130.07319.35
5.4.420.0000.06319.29
5.4.410.0000.05719.32
5.4.400.0130.06318.95
5.4.390.0000.07718.87
5.4.380.0030.07719.13
5.4.370.0030.08019.18
5.4.360.0070.07319.03
5.4.350.0000.06718.90
5.4.340.0130.08019.13
5.4.320.0000.07019.09
5.4.310.0030.06719.03
5.4.300.0030.03719.13
5.4.290.0000.05719.03
5.4.280.0100.07319.17
5.4.270.0100.07019.04
5.4.260.0030.08018.85
5.4.250.0100.06719.03
5.4.240.0000.05318.84
5.4.230.0070.07319.02
5.4.220.0030.08018.82
5.4.210.0030.05018.94
5.4.200.0100.06719.16
5.4.190.0070.04019.02
5.4.180.0070.03318.94
5.4.170.0070.07319.17
5.4.160.0100.06719.07
5.4.150.0000.05319.18
5.4.140.0070.07016.43
5.4.130.0030.04016.45
5.4.120.0000.07016.34
5.4.110.0100.04716.39
5.4.100.0030.03316.43
5.4.90.0030.03316.42
5.4.80.0030.03316.49
5.4.70.0000.06716.48
5.4.60.0000.06016.48
5.4.50.0000.03716.47
5.4.40.0030.05316.54
5.4.30.0030.03716.40
5.4.20.0000.03716.39
5.4.10.0070.06016.36
5.4.00.0000.07715.64
5.3.290.0000.04014.79
5.3.280.0030.05014.53
5.3.270.0030.03714.59
5.3.260.0000.04314.64
5.3.250.0000.03714.67
5.3.240.0030.07014.68
5.3.230.0000.04014.70
5.3.220.0000.06014.58
5.3.210.0000.04314.50
5.3.200.0000.03714.60
5.3.190.0070.03714.50
5.3.180.0000.03714.63
5.3.170.0000.07714.64
5.3.160.0030.04314.71
5.3.150.0030.03714.58
5.3.140.0030.07014.63
5.3.130.0030.03714.57
5.3.120.0070.06714.61
5.3.110.0030.03714.56
5.3.100.0000.04714.00
5.3.90.0030.04314.06
5.3.80.0070.07313.93
5.3.70.0070.06014.09
5.3.60.0000.05013.91
5.3.50.0000.04013.96
5.3.40.0030.07014.05
5.3.30.0030.06713.80
5.3.20.0000.03713.76
5.3.10.0000.05013.60
5.3.00.0000.04713.55
5.2.170.0070.06012.20
5.2.160.0000.03712.20
5.2.150.0000.04312.20
5.2.140.0000.03012.20
5.2.130.0030.02712.20
5.2.120.0000.03312.20
5.2.110.0000.03012.20
5.2.100.0030.02712.20
5.2.90.0030.02712.20
5.2.80.0070.02312.20
5.2.70.0000.03012.20
5.2.60.0000.03012.20
5.2.50.0070.05712.20
5.2.40.0000.04012.20
5.2.30.0030.07012.20
5.2.20.0000.06012.20
5.2.10.0000.06012.20
5.2.00.0070.05012.20
5.1.60.0070.04312.20
5.1.50.0030.05712.20
5.1.40.0000.05012.20
5.1.30.0070.05312.20
5.1.20.0030.05012.20
5.1.10.0030.05312.20
5.1.00.0070.05012.20
5.0.50.0000.04712.20
5.0.40.0000.03312.20
5.0.30.0000.06712.20
5.0.20.0070.04012.20
5.0.10.0030.02712.20
5.0.00.0000.06312.20
4.4.90.0030.01312.20
4.4.80.0030.01312.20
4.4.70.0000.04012.20
4.4.60.0030.03712.20
4.4.50.0000.03712.20
4.4.40.0000.05312.20
4.4.30.0000.03712.20
4.4.20.0030.03712.20
4.4.10.0030.03312.20
4.4.00.0030.04312.20
4.3.110.0000.03712.20
4.3.100.0030.03312.20
4.3.90.0000.03312.20
4.3.80.0000.03012.20
4.3.70.0000.03312.20
4.3.60.0030.01712.20
4.3.50.0030.02312.20
4.3.40.0000.05012.20
4.3.30.0000.01712.20
4.3.20.0030.03712.20
4.3.10.0000.03712.20
4.3.00.0000.03712.20

preferences:
50.24 ms | 401 KiB | 5 Q