3v4l.org

run code in 300+ PHP versions simultaneously
<?php $msg=(string)($_GET['message']?? $_POST['message'] ?? "no message!"); $answer=NULL; var_dump(getcwd()); register_shutdown_function(function()use(&$answer){ var_dump(getcwd()); file_put_contents(__DIR__.DIRECTORY_SEPARATOR.'msg.log.txt',json_encode(['answer'=>$answer,'$_GET'=>$_GET],JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_LINE_TERMINATORS ),FILE_APPEND|LOCK_EX); }); $matches=NULL; $isMatch=preg_match("/(\d+)\s*(\+|\-|\*|\/|\:)\s*(\d+)/",$msg,$matches); if($isMatch){ $l=(int)$matches[1]; $o=$matches[2]; $r=(int)$matches[3]; switch($o){ case '+': $res=$l+$r; break; case '-': $res=$l-$r; break; case '*': $res=$l*$r; break; case '/': case ':': $res=$l/$r; break; default: throw new \LogicException("invalid operator passed regex??!"); } $answer="!check {$res}"; echo $answer; }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
string(1) "/" string(1) "/" Warning: file_put_contents(/in/msg.log.txt): Failed to open stream: Permission denied in /in/fuRZs on line 7
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 string(1) "/" string(1) "/" Warning: file_put_contents(/in/msg.log.txt): Failed to open stream: Permission denied in /in/fuRZs on line 7
Output for 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
string(1) "/" string(1) "/" Warning: file_put_contents(/in/msg.log.txt): failed to open stream: Permission denied in /in/fuRZs on line 7

preferences:
175.54 ms | 402 KiB | 153 Q