How to determine if Pear is installed in PHP

Posted in Articles

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

Suppose you are on a shared webhost with PHP.  You want to know if the commonly used Pear package is installed in this PHP installation.

Just write the following PHP code  into a file named check.php and upload to your server…

require_once 'System.php';
if (class_exists('System')) {
 echo 'got Pear';
} else {
 echo 'no Pear';

You should get the output “got Pear” if Pear is installed in your PHP environment.  “System.php” is in every Pear installation.

Alternatively, you can use the sample code found in the  Pear Manual …

require_once 'System.php';
var_dump(class_exists('System', false));

Should return bool(true) if you got Pear installed.