3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getBaseURLPath() { return 'https://example.com/sub-directory/'; } function getBaseURLPathOnly() { return '/'; } function buildWithBaseURLPathOld($info, $baseURLPath) { $result = ''; if (!empty($baseURLPath)) { $result = $baseURLPath; if (!empty($info)) { $path = explode('/', $info); // Remove base path from the path info. $extractedInfo = array_pop($path); if (!empty($extractedInfo)) { $result .= $extractedInfo; } } } return $result; } function buildWithBaseURLPathNew($info, $baseURLPath) { $result = ''; if (!empty($baseURLPath)) { $result = $baseURLPath; if (!empty($info)) { // Remove base path from the path info. $extractedInfo = str_replace($baseURLPath, '', $info); // Remove starting and ending slash. $extractedInfo = trim($extractedInfo, '/'); if (!empty($extractedInfo)) { $result .= $extractedInfo; } } } return $result; } echo "Old: " . buildWithBaseURLPathOld('saml/acs',getBaseURLPath()) . PHP_EOL; echo "New: " . buildWithBaseURLPathNew('saml/acs',getBaseURLPath()) . PHP_EOL; echo "Old: " . buildWithBaseURLPathOld('/saml/acs',getBaseURLPath()) . PHP_EOL; echo "New: " . buildWithBaseURLPathNew('/saml/acs',getBaseURLPath()) . PHP_EOL; echo "Old: " . buildWithBaseURLPathOld('/',getBaseURLPath()) . PHP_EOL; echo "New: " . buildWithBaseURLPathNew('/',getBaseURLPath()) . PHP_EOL; echo "Old: " . buildWithBaseURLPathOld('',getBaseURLPath()) . PHP_EOL; echo "New: " . buildWithBaseURLPathNew('',getBaseURLPath()) . PHP_EOL; // Case not considered where URL is not a URL... echo "Old: " . buildWithBaseURLPathOld('saml/acs',getBaseURLPathOnly()) . PHP_EOL; echo "New: " . buildWithBaseURLPathNew('saml/acs',getBaseURLPathOnly()) . PHP_EOL; echo "Old: " . buildWithBaseURLPathOld('/saml/acs',getBaseURLPathOnly()) . PHP_EOL; echo "New: " . buildWithBaseURLPathNew('/saml/acs',getBaseURLPathOnly()) . PHP_EOL; echo "Old: " . buildWithBaseURLPathOld('/',getBaseURLPathOnly()) . PHP_EOL; echo "New: " . buildWithBaseURLPathNew('/',getBaseURLPathOnly()) . PHP_EOL; echo "Old: " . buildWithBaseURLPathOld('',getBaseURLPathOnly()) . PHP_EOL; echo "New: " . buildWithBaseURLPathNew('',getBaseURLPathOnly()) . 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.3.120.0100.00019.04
8.3.110.0160.00416.59
8.3.100.0270.00616.38
8.3.90.0230.00416.80
8.3.80.0190.01916.67
8.3.70.0350.00416.55
8.3.60.0190.01116.53
8.3.50.0280.01016.71
8.3.40.0180.01117.45
8.3.30.0160.00817.46
8.3.20.0250.00617.39
8.3.10.0200.00417.50
8.3.00.0070.00317.52
8.2.240.0080.00016.37
8.2.230.0140.00716.51
8.2.220.0190.00016.34
8.2.210.0160.00616.68
8.2.200.0140.00716.54
8.2.190.0150.00616.39
8.2.180.0160.00616.48
8.2.170.0140.00717.71
8.2.160.0160.00417.69
8.2.150.0170.00317.57
8.2.140.0130.00517.53
8.2.130.0190.00517.73
8.2.120.0190.00017.52
8.2.110.0140.00617.58
8.2.100.0210.00417.59
8.2.90.0200.00717.58
8.2.80.0350.00717.60
8.2.70.0230.00317.67
8.2.60.0230.00017.55
8.2.50.0250.01117.62
8.2.40.0290.00517.39
8.2.30.0160.00617.68
8.2.20.0250.00017.48
8.2.10.0150.00617.52
8.2.00.0170.00017.49
8.1.300.0070.01116.31
8.1.290.0120.00816.18
8.1.280.0180.00016.21
8.1.270.0190.00317.13
8.1.260.0240.00017.40
8.1.250.0250.00017.20
8.1.240.0100.01317.35
8.1.230.0170.00017.43
8.1.220.0140.00717.07
8.1.210.0130.00317.19
8.1.200.0190.00017.00
8.1.190.0130.00817.17
8.1.180.0150.00617.26
8.1.170.0120.00517.25
8.1.160.0170.00417.04
8.1.150.0180.00217.12
8.1.140.0160.00317.15
8.1.130.0150.00416.97
8.1.120.0190.00417.20
8.1.110.0090.00917.13
8.1.100.0200.00017.43
8.1.90.0160.00316.91
8.1.80.0160.00517.27
8.1.70.0100.00716.98
8.1.60.0100.01017.16
8.1.50.0160.00417.08
8.1.40.0160.00317.36
8.1.30.0150.00417.41
8.1.20.0180.00017.21
8.1.10.0130.00617.29
8.1.00.0140.00517.08

preferences:
36.35 ms | 403 KiB | 5 Q