3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php method_exists('SplFileObject', 'fread') or die("No SplFileObject::fread()"); $i=0; $file = new SplFileObject(__FILE__); while ($file->valid()) { $chunk = $file->fread(20); $hex = array_map(function ($char) { return sprintf('%02X', ord($char)); }, str_split($chunk)); printf("%s %s\n", implode(' ', $hex), preg_replace('/[[:print:]]/', '.', $chunk)); }
based on NWdDv
Output for 5.5.24 - 7.1.0
3C 3F 70 68 70 0A 0A 6D 65 74 68 6F 64 5F 65 78 69 73 74 73 ..... ............. 28 27 53 70 6C 46 69 6C 65 4F 62 6A 65 63 74 27 2C 20 27 66 .................... 72 65 61 64 27 29 20 6F 72 20 64 69 65 28 22 4E 6F 20 53 70 .................... 6C 46 69 6C 65 4F 62 6A 65 63 74 3A 3A 66 72 65 61 64 28 29 .................... 22 29 3B 0A 24 69 3D 30 3B 0A 24 66 69 6C 65 20 3D 20 6E 65 ... ..... .......... 77 20 53 70 6C 46 69 6C 65 4F 62 6A 65 63 74 28 5F 5F 46 49 .................... 4C 45 5F 5F 29 3B 0A 77 68 69 6C 65 20 28 24 66 69 6C 65 2D ...... ............. 3E 76 61 6C 69 64 28 29 29 20 7B 0A 09 24 63 68 75 6E 6B 20 ........... ....... 3D 20 24 66 69 6C 65 2D 3E 66 72 65 61 64 28 32 30 29 3B 0A ................... 20 20 20 20 24 68 65 78 20 20 20 3D 20 61 72 72 61 79 5F 6D .................... 61 70 28 66 75 6E 63 74 69 6F 6E 20 28 24 63 68 61 72 29 20 .................... 7B 20 72 65 74 75 72 6E 20 73 70 72 69 6E 74 66 28 27 25 30 .................... 32 58 27 2C 20 6F 72 64 28 24 63 68 61 72 29 29 3B 20 7D 2C .................... 20 73 74 72 5F 73 70 6C 69 74 28 24 63 68 75 6E 6B 29 29 3B .................... 0A 20 20 20 20 70 72 69 6E 74 66 28 22 25 73 20 20 20 20 25 ................... 73 5C 6E 22 2C 20 69 6D 70 6C 6F 64 65 28 27 20 27 2C 20 24 .................... 68 65 78 29 2C 20 70 72 65 67 5F 72 65 70 6C 61 63 65 28 27 .................... 2F 5B 5B 3A 70 72 69 6E 74 3A 5D 5D 2F 27 2C 20 27 2E 27 2C .................... 20 24 63 68 75 6E 6B 29 29 3B 0A 7D .......... .
Output for 5.3.0 - 5.4.45
No SplFileObject::fread()
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/9oYe4 on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/9oYe4 on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/9oYe4 on line 8
Process exited with code 255.