Re: PHP_Func
| From: | Aidan Lister | Date: | Sun, 02 May 2004 01:05:21 +0000 |
| Subject: | Re: PHP_Func | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-28681@lists.php.net to get a copy of this message | ||
What name are we going with?
PHP_Compat
Or
PHP_Compatability
"Alan Knowles" <alan@akbkhome.com> wrote in message
news:408DB533.4060506@akbkhome.com...
> Although PEAR is supposted to be a class library, we did discuss this as
> part of the PHP_CompactInfo proposal.. - I do wonder if this should not
> be made available as part of PEAR
>
> PEAR::ensureFunction('file_get_contents');
>
> function ensureFunction($name) {
> if (function_exists($name)) {
> return;
> }
> require_once 'PEAR/CompatFunctions/'.$name.'.php';
> }
>
> .. the actual CompatFunctions could be in the PEAR_CompatFunctions
> package...
>
> i dont think getting clever and putting them in a class would be quite
> as predictable as just defining the function...
>
> Feel free to propose it..
> ** I could really do with the clone one :)
>
> Regards
> Alan
>
>
>
>
> Aidan Lister wrote:
> > I was thinking to myself, why doesn't PEAR have a set of functions that
> > everyone, for every project ends up rewriting? Surely that's what we're
> > about here, reusability.
> >
> >
> > include 'function.microtime_str.php'; // tell me you haven't recreated
this
> > function at least 100 times
> >
> > http://ircphp.com/users/imho/?file=function.microtime_str.php
> >
> > Then I was thinking, well, why stop there - why not introduce
> > implementations of functions that are lacking in older versions of php -
god
> > knows the PHP Manual is full of them.
> >
> > For example,
> > http://ircphp.com/users/imho/?file=function.scandir.php
> >
> > http://ircphp.com/users/imho/?file=function.file_get_contents.php
> >
> > http://ircphp.com/users/imho/?file=function.file_put_contents.php
> >
> > Then lsmith said "why not put them in a class", and immediately my brain
> > started ticking.
> >
> > PHP_Func, a class for extending and replacing basic PHP functionality.
All
> > functions would be abstract, and called as such.
> >
> > eg. PHP_Func::file_get_contents();
> >
> > In a PHP5 implementation, the __get method could be used for a factory
> > pattern.
> >
> > Anyway, that's my idea... I'd love any feedback, whether people think
it's a
> > good idea, etc.
> >
> >
> > Thanks,
> > Aidan
> >
>
>
> --
> Can you help out?
> Need Consulting Services or Know of a Job?
> http://www.akbkhome.com