Re: cvs: pear /Archive_Tar Tar.php

From: Date: Thu, 11 Oct 2001 16:00:33 +0000
Subject: Re: cvs: pear /Archive_Tar Tar.php
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-2249@lists.php.net to get a copy of this message
On Thu, Oct 11, 2001 at 11:42:16AM -0000, Thomas V.V.Cox wrote: > cox Thu Oct 11 07:42:16 2001 EDT > > Modified files: > /pear/Archive_Tar Tar.php > Log: > assert zlib extension support or die [snip] > + if ($p_compress) { // assert zlib extension support > + $extname = 'zlib'; > + if (!extension_loaded($extname)) { > + $dlext = (substr(PHP_OS, 0, 3) == 'WIN') ? '.dll' : > '.so'; > + @dl($extname . $dlext); > + } > + if (!extension_loaded($extname)) { > + die("The extension '$extname' couldn't be loaded. ". > + 'Probably you don\'t have support in your PHP '. > + 'to this extension'); > + return false; > + } > + } Over in Horde-land, we have a little static function to handle these kinds of prerequisite checks: /** * Check for the existence of the given function. * * @access public * * @param string $function The name of the function to test. * @param boolean $fatal (optional) Exit fatally if $function doesn't * exist. * @param boolean $complaint (optional) Display an error message if * $function doesn't exist. * * @return boolean The availability of $function. */ function functionCheck($function, $fatal = false, $complaint = '') { if (function_exists($function)) { return true; } else { if (!empty($complaint)) { echo "<h2>$complaint</h2>\n"; } if ($fatal) { exit; } return false; } } Perhaps something similar should be added to the PEAR class as a static method. That would keep the test in a common place so that each PEAR package wouldn't have to duplicate the functionality. -- Jon Parise (jon@csh.rit.edu) . Information Technology (2001) http://www.csh.rit.edu/~jon/ : Computer Science House Member

« previous php.pear.dev (#2249) next »