Update hg.php

fixed variable checking in magic functions