3v4l.org

run code in 300+ PHP versions simultaneously
<?php function readUnsignedVarLong(string $buffer, int &$offset) : int{ $value = 0; for($i = 0; $i <= 63; $i += 7){ if(!isset($buffer[$offset])){ throw new Exception("No bytes left in buffer"); } $b = ord($buffer[$offset++]); $value |= (($b & 0x7f) << $i); if(($b & 0x80) === 0){ return $value; } } throw new Exception("VarLong did not terminate after 10 bytes!"); } $a = 0; var_dump(readUnsignedVarLong(str_repeat("\255", 10), $a));
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Exception: VarLong did not terminate after 10 bytes! in /in/3Q2gR:17 Stack trace: #0 /in/3Q2gR(20): readUnsignedVarLong('\xAD\xAD\xAD\xAD\xAD\xAD\xAD\xAD\xAD\xAD', 10) #1 {main} thrown in /in/3Q2gR on line 17
Process exited with code 255.

preferences:
120.85 ms | 402 KiB | 89 Q