3v4l.org

run code in 300+ PHP versions simultaneously
<?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)); }
Output for git.master, git.master_jit, rfc.property-hooks
3C 3F 70 68 70 0A 0A 6D 65 74 68 6F 64 5F 65 78 69 73 74 73 <?php..method_exists 28 27 53 70 6C 46 69 6C 65 4F 62 6A 65 63 74 27 2C 20 27 66 ('SplFileObject', 'f 72 65 61 64 27 29 20 6F 72 20 64 69 65 28 22 4E 6F 20 53 70 read') or die("No Sp 6C 46 69 6C 65 4F 62 6A 65 63 74 3A 3A 66 72 65 61 64 28 29 lFileObject::fread() 22 29 3B 0A 24 69 3D 30 3B 0A 24 66 69 6C 65 20 3D 20 6E 65 ");.$i=0;.$file = ne 77 20 53 70 6C 46 69 6C 65 4F 62 6A 65 63 74 28 5F 5F 46 49 w SplFileObject(__FI 4C 45 5F 5F 29 3B 0A 77 68 69 6C 65 20 28 24 66 69 6C 65 2D LE__);.while ($file- 3E 76 61 6C 69 64 28 29 29 20 7B 0A 09 24 63 68 75 6E 6B 20 >valid()) {..$chunk 3D 20 24 66 69 6C 65 2D 3E 66 72 65 61 64 28 32 30 29 3B 0A = $file->fread(20);. 20 20 20 20 24 68 65 78 20 20 20 3D 20 61 72 72 61 79 5F 6D $hex = array_m 61 70 28 66 75 6E 63 74 69 6F 6E 20 28 24 63 68 61 72 29 20 ap(function ($char) 7B 20 72 65 74 75 72 6E 20 73 70 72 69 6E 74 66 28 27 25 30 { return sprintf('%0 32 58 27 2C 20 6F 72 64 28 24 63 68 61 72 29 29 3B 20 7D 2C 2X', ord($char)); }, 20 73 74 72 5F 73 70 6C 69 74 28 24 63 68 75 6E 6B 29 29 3B str_split($chunk)); 0A 20 20 20 20 70 72 69 6E 74 66 28 22 25 73 20 20 20 20 25 . printf("%s % 73 5C 6E 22 2C 20 69 6D 70 6C 6F 64 65 28 27 20 27 2C 20 24 s\n", implode(' ', $ 68 65 78 29 2C 20 70 72 65 67 5F 72 65 70 6C 61 63 65 28 27 hex), preg_replace(' 2F 5B 5E 5B 3A 70 72 69 6E 74 3A 5D 5D 2F 27 2C 20 27 2E 27 /[^[:print:]]/', '.' 2C 20 24 63 68 75 6E 6B 29 29 3B 0A 7D , $chunk));.}

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
42.34 ms | 405 KiB | 8 Q