Sizecoding isn’t just for the demoscene. You may have seen the wonderful JS1K competitions or perhaps many of the 4k entries from various demoparties including most famously Elevated by RGBA + TBC (YouTube).

I can’t code. I keep saying that but for some reason I like to play around with PHP, making simple scripts for my own amusement. One idea I had was to make a simple messaging system (like you see on web forums) in 1k. I’m still building that (for fun – it might never get finished though!), but I did spend a bit of time making a PHP packer using the gzdeflate function.

If you’re interested, here’s the code:

$d='<?php $z=fopen("index.php","r");fseek($z,79);eval(gzinflate(fread($z,9999)));?>';

Provide it with an input.php and it will give you a self-extracting compressed file index.php.

It’s good for files up to 9999 bytes – if you need more, edit the 9999 to the amount of decompressed bytes needed and make sure that the 79 equals to 75 plus the amount of digits in your decompressed byte count (essentially, the length of the decompression code in the $d string).

Nothing amazing but a bit of fun!