3v4l.org

run code in 300+ PHP versions simultaneously
<?php function oldTextual($steamid) { $result = 'Invalid input.'; if (!preg_match('([a-zA-Z])', $steamid) && strlen($steamid) === 17) { // 64-bit int $acc_id = bcsub($steamid, '76561197960265728'); $result = 'STEAM_0:'; if ($acc_id % 2 === 0) $result .= '0:'; else $result .= '1:'; $result .= bcdiv($acc_id, '2', 0); } if (substr($steamid, 0, 2) === "U:") { // New textual format $split = explode(':', $steamid); $result = 'STEAM_0:'; $z = (int)$split[2]; if ($z % 2 === 0) $result .= '0:'; else $result .= '1:'; $acc_id = bcdiv($z, '2', 0); $result .= $acc_id; } return $result; } function newTextual($steamid) { $result = 'Invalid input.'; if (substr($steamid, 0, 6) === 'STEAM_') { // Old textual format $split = explode(':', $steamid); $y = $split[1]; $z = $split[2]; $acc_id = bcadd(bcmul($z, '2'), $y); $result = 'U:1:' . $acc_id; } if (!preg_match('([a-zA-Z])', $steamid) && strlen($steamid) === 17) { // 64-bit int $acc_id = bcsub($steamid, '76561197960265728'); $result = 'U:1:' . $acc_id; } return $result; } function numeric($steamid) { $result = 'Invalid input.'; if (substr($steamid, 0, 6) === 'STEAM_') { // Old textual format $split = explode(':', $steamid); $commid = bcmul($split[2], '2'); if ($split[1] === '1') $commid = bcadd($commid, '1'); $result = bcadd($commid, '76561197960265728'); } if (substr($steamid, 0, 2) === "U:") { // New textual format $filter = str_replace(array('[', ']'), '', $steamid); $split = explode(':', $filter); $result = bcadd($split[2], '76561197960265728'); } return $result; } $steamid64 = '76561198074715892'; $steamid32 = 'STEAM_0:0:57225082'; $steamid3 = 'U:1:114450164'; echo oldTextual($steamid64) . '<br>'; echo oldTextual($steamid3) . '<br>'; echo newTextual($steamid64) . '<br>'; echo newTextual($steamid32) . '<br>'; echo 'http://steamcommunity.com/profiles/' . numeric($steamid32) . '<br>'; echo 'http://steamcommunity.com/profiles/' . numeric($steamid3);
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
STEAM_0:0:57225082<br>STEAM_0:0:57225082<br>U:1:114450164<br>U:1:114450164<br>http://steamcommunity.com/profiles/76561198074715892<br>http://steamcommunity.com/profiles/76561198074715892
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 STEAM_0:0:57225082<br>STEAM_0:0:57225082<br>U:1:114450164<br>U:1:114450164<br>http://steamcommunity.com/profiles/76561198074715892<br>http://steamcommunity.com/profiles/76561198074715892
Output for 7.3.32 - 7.3.33, 7.4.33, 8.0.13
Fatal error: Uncaught Error: Call to undefined function bcsub() in /in/USdlZ:6 Stack trace: #0 /in/USdlZ(81): oldTextual('765611980747158...') #1 {main} thrown in /in/USdlZ on line 6
Process exited with code 255.
Output for 5.5.0 - 5.5.38
Fatal error: Call to undefined function bcsub() in /in/USdlZ on line 6
Process exited with code 255.

preferences:
241.85 ms | 401 KiB | 354 Q