<?php $str = 'hello world'; $enc = zlib_encode($str, ZLIB_ENCODING_DEFLATE); echo bin2hex($enc); // 789ccb48cdc9c95728cf2fca4901001a0b045d ?>