PHP5 Upgrade

Updated for PHP, removed deprecated functions, updated comment style to
PHPDoc, added exception throwing for errors, added variable prefix of
'$', fixed implied multiplication issue when near parenthesis.