Re: Re: [ANNOUNCEMENT] Contact_Vcard_Parse-1.30 (stable) Released.
| From: | Paul M Jones | Date: | Wed, 18 Feb 2004 22:33:11 +0000 |
| Subject: | Re: Re: [ANNOUNCEMENT] Contact_Vcard_Parse-1.30 (stable) Released. | ||
| References: | 1 2 | Groups: | php.pear.dev php.pear.general |
| Request: | Send a blank email to pear-dev+get-25704@lists.php.net to get a copy of this message | ||
Hi,
the better approach would have been to do something like this:
if(!function_exists("file_get_contents"))
{
function file_get_contents($filename, $use_include_path = 0)
{
$data = ''; // just to be safe. Dunno, if this is really needed
$file = @fopen($filename, 'rb', $use_include_path);
if($file)
{
while (!feof($file)) $data .= fread($file, 1024);
fclose($file);
}
return $data;
}
}
I thought of that, but I am paranoid about polluting the global function space.
I don't like it when a class file also defines global functions; in my little world, a PEAR class file (really, any class file) should only define its class and class-related constants, nothing more, and certainly not global functions.
The end-user (or another PEAR class) may already be using the function name, either for the same purpose or not (and if for the same purpose then it may not use the same parameters or logic, thus breaking the class code that depends on it).
The "better approach" you note has a higher probability of a name collision in the global namespace, and I want to avoid that. Thus, I think the method used in Contact_Vcard_Parse is safer when combined with an unknown code base (which the end-user code base certainly is) ... but that's just me.
--
Paul M. Jones
Savant: the simple alternative to Smarty.
http://phpsavant.com/