Simple .php package check

I have no knowledge of php so rather than figure this out again here’s what I did. Probably has a million mistakes.

require_once 'PEAR/Registry.php'; 
// First see what the command line does
print("<p>pear list<br>");
$output = shell_exec('pear list'); 
echo "$output";
// Now see what we get
$pear = new PEAR_Config();
$pear_reg = $pear->getRegistry();
$pear_info = $pear_reg->packageInfo("PEAR");
$pear_list = $pear_reg->listPackages();
$result = count($pear_list);
echo "\n<p> pear_list has element count of ";
echo "$result </p>\n";

foreach ($pear_list as $value)
echo "    <br>\n";
echo "\n=====================================================<br>";
require_once 'PEAR/Info.php';
$res = PEAR_Info::packageInstalled("Mail_Mime");
echo "$res <br>\n";
Friday, October 28th, 2016 Linux