3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_start = explode(" ", microtime()); $_sys['load'][] = ($_start[1] + $_start[0]) - $_sys['load'][0]; unset($_start); function format_string($value) { $value = trim( preg_replace("/[^\p{L}\p{N}!?@#$%_^{}.,|&*+\-():\[\]\/\\\]/u", " ", html_entity_decode($value, ENT_QUOTES, "UTF-8"))); if (!empty($value)) { return $value; } else { return false; } } function format_string_import($value) { $value = str_replace("-_", "-", str_replace("_-", "-", str_replace("_-_", "-", preg_replace('/_+/', '_', preg_replace('/-+/', '-', strtolower( trim( preg_replace("/[^\p{L}\p{N}-\'\"_]/u", "_", html_entity_decode($value, ENT_QUOTES, "UTF-8") ) ) ) ) ) ) )); while (isset($value[0]) && $value[0] == "_") { $value = substr($value, 1); } while (isset($value[0]) && $value[0] == "-") { $value = substr($value, 0, -1); } while (isset($value[0]) && substr($value, -1) == "-") { $value = substr($value, 0, -1); } while (isset($value[0]) && substr($value, -1) == "_") { $value = substr($value, 0, -1); } if (isset($value[0])) { return $value; } else { return false; } } function format_num($value) { $value = (int)preg_replace("/[^0-9]/", null, $value); if (isset($value[0])) { return $value; } else { return false; } } function mmc_query($q, $server = 0) { if (!empty($q)) { if ($GLOBALS['_config']['sql_cache'] == 1) { if ($d = mmc_read($q, $server)) { return unserialize(base64_decode($d)); } else { if ($d = read_mysql($q, $server)) { mmc_send($q, base64_encode(serialize($d)), $server); return $d; } else { return false; } } } else { return read_mysql($q, $server); } } else { return false; } } function mmc_read($o, $server = 0) { if (!empty($o)) { if (!isset($GLOBALS['MEMCACHE'][$server])) { $GLOBALS['MEMCACHE'][$server] = memcache_connect($GLOBALS['_config']['memcached_host'][$server], 0); } if ($r = memcache_get($GLOBALS['MEMCACHE'][$server], md5($o . $_SERVER['SERVER_NAME']))) { return unserialize($r); } else { return false; } } else { return false; } } function mmc_send($o, $data, $server = 0) { if (!empty($o)) { if (!isset($GLOBALS['MEMCACHE'][$server])) { $GLOBALS['MEMCACHE'][$server] = memcache_connect($GLOBALS['_config']['memcached_host'][$server], 0); } memcache_set( $GLOBALS['MEMCACHE'][$server], md5($o . $_SERVER['SERVER_NAME']), serialize($data), $GLOBALS['_config']['memcached_compress'], $GLOBALS['_config']['memcached_time'] ); } } function mmc_replace($o, $data, $server = 0) { if (!empty($o)) { if (!isset($GLOBALS['MEMCACHE'][$server])) { $GLOBALS['MEMCACHE'][$server] = memcache_connect($GLOBALS['_config']['memcached_host'][$server], 0); } memcache_replace( $GLOBALS['MEMCACHE'][$server], md5($o . $_SERVER['SERVER_NAME']), serialize($data), $GLOBALS['_config']['memcached_compress'], $GLOBALS['_config']['memcached_time'] ); } } function read_mysql($q, $server = 0) { if (!empty($q)) { if (!isset($GLOBALS['MYSQL'][$server])) { $GLOBALS['MYSQL'][$server] = mysqli_connect($GLOBALS['_config']['mysql_host'][$server], $GLOBALS['_config']['mysql_user'][$server], $GLOBALS['_config']['mysql_pass'][$server], $GLOBALS['_config']['mysql_database'][$server]); } if ($r = mysqli_query($GLOBALS['MYSQL'][$server], $q)) { if ($r->num_rows > 0) { $d = array(); while ($row = mysqli_fetch_assoc($r)) { $d[] = $row; } return $d; } else { return false; } } else { return false; } } else { return false; } } function last_mysql_id($server = 0) { if (isset($GLOBALS['MYSQL'][$server])) { if (!empty($GLOBALS['MYSQL'][$server]->insert_id)) { return $GLOBALS['MYSQL'][$server]->insert_id; } else { return false; } } else { return false; } } function send_mysql($q, $server = 0) { if (!empty($q)) { if (!isset($GLOBALS['MYSQL'][$server])) { $GLOBALS['MYSQL'][$server] = mysqli_connect($GLOBALS['_config']['mysql_host'][$server], $GLOBALS['_config']['mysql_user'][$server], $GLOBALS['_config']['mysql_pass'][$server], $GLOBALS['_config']['mysql_database'][$server]); } mysqli_query($GLOBALS['MYSQL'][$server], $q); } } function encrypt($key, $value) { return base64_encode(openssl_encrypt($value, "AES-128-CBC", $key, 0, substr(md5($key), 0, 16))); } function decrypt($key, $value) { return openssl_decrypt(base64_decode($value), "AES-128-CBC", $key, 0, substr(md5($key), 0, 16)); } function send_mail($to, $to_name, $subject, $body) { require_once("Mail.php"); $to = $to_name . " <" . $to . ">"; $headers = array( 'From' => $GLOBALS['_config']['email_name'] . " <" . $GLOBALS['_config']['email'] . ">", 'To' => $to, 'Subject' => $subject, ); $smtp = Mail::factory( 'smtp', array( 'host' => $GLOBALS['_config']['email_host'], 'auth' => true, 'username' => $GLOBALS['_config']['email_login'], 'password' => $GLOBALS['_config']['email_pass'], ) ); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { //return($mail->getMessage()); return false; } else { return true; } } ?>

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)
7.4.10.0090.00914.80
7.4.00.0060.01215.06
7.3.130.0040.01215.11
7.3.120.0060.01214.93
7.3.110.0130.00715.10
7.3.100.0070.01014.91
7.3.90.0090.00614.78
7.3.80.0070.00714.91
7.3.70.0040.00714.89
7.3.60.0110.00314.71
7.3.50.0070.00714.78
7.3.40.0030.01014.68
7.3.30.0090.00314.75
7.3.20.0120.00616.55
7.3.10.0040.01116.61
7.3.00.0130.00316.59
7.2.260.0100.00315.04
7.2.250.0080.01115.07
7.2.240.0000.01514.91
7.2.230.0030.01014.81
7.2.220.0000.01515.14
7.2.210.0040.01114.91
7.2.200.0100.00315.18
7.2.190.0030.01215.30
7.2.180.0000.01314.84
7.2.170.0060.00915.04
7.2.160.0070.01014.95
7.2.150.0040.01416.51
7.2.140.0110.00316.79
7.2.130.0040.00716.76
7.2.120.0100.00716.84
7.2.110.0030.00916.71
7.2.100.0030.00916.66
7.2.90.0110.00316.88
7.2.80.0060.00916.94
7.2.70.0040.00716.82
7.2.60.0030.01017.00
7.2.50.0040.01116.64
7.2.40.0120.00316.97
7.2.30.0090.00616.79
7.2.20.0040.01516.93
7.2.10.0000.01116.86
7.2.00.0060.00916.80
7.1.330.0060.00815.83
7.1.320.0040.01115.89
7.1.310.0070.00715.77
7.1.300.0080.00615.70
7.1.290.0070.00715.79
7.1.280.0030.01015.75
7.1.270.0140.00015.99
7.1.260.0060.00915.75
7.1.250.0070.00315.87
7.1.240.0060.00615.81
7.1.230.0050.00815.79
7.1.220.0080.00315.75
7.1.210.0060.00315.64
7.1.200.0000.01415.88
7.1.190.0040.00715.90
7.1.180.0090.00615.77
7.1.170.0060.00615.79
7.1.160.0040.01115.55
7.1.150.0130.00315.76
7.1.140.0000.00915.70
7.1.130.0000.01015.93
7.1.120.0060.00615.89
7.1.110.0030.01015.68
7.1.100.0030.01015.77
7.1.90.0060.01215.87
7.1.80.0090.00915.92
7.1.70.0060.01116.47
7.1.60.0100.00825.41
7.1.50.0130.00825.24
7.1.40.0120.01025.17
7.1.30.0110.01225.05
7.1.20.0180.01025.35
7.1.10.0030.01216.21
7.1.00.0050.00815.99
7.0.330.0000.00915.35
7.0.320.0040.00815.55
7.0.310.0040.01115.03
7.0.300.0100.00315.29
7.0.290.0040.00415.27
7.0.280.0000.01515.45
7.0.270.0100.00315.27
7.0.260.0040.00815.42
7.0.250.0090.00615.43
7.0.240.0060.00915.48
7.0.230.0060.00915.24
7.0.220.0060.00915.09
7.0.210.0030.00715.44
7.0.200.0000.01115.96
7.0.190.0070.00816.09
7.0.180.0050.01315.83
7.0.170.0050.01415.88
7.0.160.0020.01115.80
7.0.150.0070.00915.74
7.0.140.0100.00815.84
7.0.130.0080.00615.96
7.0.120.0060.00615.96
7.0.110.0070.00615.79
7.0.100.0040.00915.87
7.0.90.0030.01015.99
7.0.80.0040.00915.97
7.0.70.0040.00915.87
7.0.60.0050.00915.61
7.0.50.0050.01116.03
7.0.40.0090.00715.01
7.0.30.0080.00415.02
7.0.20.0060.00914.96
7.0.10.0050.01014.90
7.0.00.0000.01414.98
5.6.400.0030.01014.44
5.6.390.0060.00914.75
5.6.380.0050.00314.20
5.6.370.0030.00614.16
5.6.360.0000.01314.52
5.6.350.0070.00714.27
5.6.340.0070.00714.41
5.6.330.0060.00314.35
5.6.320.0030.00614.52
5.6.310.0040.00714.36
5.6.300.0030.01014.34
5.6.290.0090.00314.10
5.6.280.0060.00914.48
5.6.270.0080.00314.67
5.6.260.0000.01514.55
5.6.250.0030.00914.25
5.6.240.0060.00314.04
5.6.230.0070.00814.63
5.6.220.0030.01014.45
5.6.210.0160.00314.57
5.6.200.0040.01214.07
5.6.190.0060.00814.37
5.6.180.0060.00914.11
5.6.170.0000.00914.35
5.6.160.0000.01414.40
5.6.150.0030.00914.49
5.6.140.0070.00414.07
5.6.130.0030.01014.58
5.6.120.0060.00914.32
5.6.110.0070.00714.25
5.6.100.0110.00314.35
5.6.90.0090.00014.74
5.6.80.0070.01014.37
5.6.70.0000.01514.14
5.6.60.0060.00614.20
5.6.50.0040.01114.23
5.6.40.0060.01013.99
5.6.30.0060.01214.41
5.6.20.0030.01314.27
5.6.10.0040.01114.19
5.6.00.0090.00914.31

preferences:
39.3 ms | 400 KiB | 5 Q