| 
<?php
 /**
 * Class used to work with the PHP modules.
 * This class cannot be extended anymore.
 *
 * @final
 */
 final class Extensions
 {
 /**
 * private member to hold the PHP loaded extensions
 *
 * @var array
 */
 private $loadedExtensions;
 
 /**
 * Constructor
 * Used to load the PHP extensions into the private member
 *
 * @return Extensions
 */
 public function Extensions()
 {
 // load into the private member the PHP loaded extensions
 $this->loadedExtensions = get_loaded_extensions();
 }
 
 /**
 * This function is used to find out if an extension has been loaded.
 * If not, try to load it at runtime.
 *
 * @param string $extension
 * @return boolean TRUE if the extension has been loaded
 * @return boolean FALSE if the extension is not available/could not be loaded
 * @throws ExifNotFound Exception
 */
 public function isLoaded($extension)
 {
 // if the extension has not been loaded,
 // try to load it at runtime
 if (!extension_loaded($extension) && !@dl($extension))
 {
 // throw the exception
 throw new ExifNotFound("The EXIF module could not be loaded !");
 
 // althought the script will not reach this point in case of exception throwing,
 // for the sake of the return, put the false value
 return false;
 }
 else
 {
 // either the module is already loaded or has been loading at runtime,
 // return true
 return true;
 }
 }
 }
 
 
 ?>
 |