3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hex_dump($data, $newline = "\n") { static $from = ''; static $to = ''; static $idxOffset = 8; static $width = 16; # number of bytes per line static $pad = '.'; # padding for non-visible characters static $hexPad = '00'; static $repeatHeadline = 5; if ($from === '') { for ($i = 0; $i <= 0xFF; ++$i) { $from .= chr($i); $to .= ($i >= 0x20 && $i <= 0x7E) ? chr($i) : $pad; } } $text = true; echo ($text) ? '' : '<pre>'; $head = str_repeat(' ', $idxOffset).' | '. implode(' ', array_map( create_function( '$str', 'return sprintf("%2X", $str);' ), range(0, $width - 1) )).' | '.(str_pad('', $width, '0123456789abcdef')).$newline; $separator = str_repeat('-', $idxOffset + 1).'+'.str_repeat('-', 3 * $width + 1).'+'. str_repeat('-', $width + 1).$newline; echo $head.$separator; $hex = str_split(bin2hex($data), $width * 2); $chars = str_split(strtr($data, $from, $to), $width); $hexLineBase = array_fill(0, $width, $hexPad); $offset = $c = 0; foreach ($hex as $i => $line) { $hexLine = str_split($line, 2) + $hexLineBase; $strLine = $chars[$i].str_repeat($pad, $width - strlen($chars[$i])); $line = sprintf('%'.$idxOffset.'X', $offset) . ' | ' . implode(' ', $hexLine) . ' | ' . $strLine . $newline; echo ($text) ? $line : htmlspecialchars($line); $offset += $width; if (++$c == $repeatHeadline) { echo $separator.$head.$separator; $c = 0; } } echo ($text) ? $newline.$newline : '<pre>'; } hex_dump(' \t\n\r\x0B'); hex_dump(" \t\n\r\x0B");
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.6
Fatal error: Uncaught Error: Call to undefined function create_function() in /in/9FgFp:30 Stack trace: #0 /in/9FgFp(63): hex_dump(' \\t\\n\\r\\x0B') #1 {main} thrown in /in/9FgFp on line 30
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Deprecated: Function create_function() is deprecated in /in/9FgFp on line 32 | 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- 0 | 20 5c 74 5c 6e 5c 72 5c 78 30 42 00 00 00 00 00 | \t\n\r\x0B..... Deprecated: Function create_function() is deprecated in /in/9FgFp on line 32 | 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- 0 | 20 09 0a 0d 0b 00 00 00 00 00 00 00 00 00 00 00 | ...............
Output for 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.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.3.32 - 7.3.33
| 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- 0 | 20 5c 74 5c 6e 5c 72 5c 78 30 42 00 00 00 00 00 | \t\n\r\x0B..... | 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- 0 | 20 09 0a 0d 0b 00 00 00 00 00 00 00 00 00 00 00 | ...............
Output for 4.4.5 - 4.4.9
| 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- Fatal error: Call to undefined function: str_split() in /in/9FgFp on line 41
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
| 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- Fatal error: Call to undefined function: str_split() in /in/9FgFp on line 41
Process exited with code 255.
Output for 4.3.0 - 4.3.1
| 0 1 2 3 4 5 6 7 8 9 A B C D E F | 0123456789abcdef ---------+-------------------------------------------------+----------------- Fatal error: Call to undefined function: str_split() in /in/9FgFp on line 41

preferences:
285.11 ms | 402 KiB | 422 Q