Php Megahal Implementation