Re: How to redefine a function if it doesn't exist?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2010-03-30 at 12:26 -0300, Igor Escobar wrote:

> See
> http://br2.php.net/manual/en/function.create-function.php
> 
> 
> Regards,
> Igor Escobar
> Systems Analyst & Interface Designer
> 
> + http://blog.igorescobar.com
> + http://www.igorescobar.com
> + @igorescobar (twitter)
> 
> 
> 
> 
> 
> On Tue, Mar 30, 2010 at 10:23 AM, David Otton <
> phpmail@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 
> > On 30 March 2010 14:16, Andre Polykanine <andre@xxxxxxxx> wrote:
> >
> > > I need a quoted_printable_encode function but it's available only
> > > since PHP 5.3. How do I redefine that function only if PHP version is
> > > lower than 5.3?
> >
> > function_exists().
> >
> > if (!function_exists('myfunc')) {
> >    function myfunc() {
> >        ;
> >    }
> > }
> >
> > http://uk3.php.net/function_exists
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >


That is only really useful for creating a function at run-time, not for
defining a function if it doesn't exist. As I and several others have
pointed out, the best way is to use function_exists() to determine
whether to create one or not. Presumably if you need to redefine a
function, you know its arguments before the code executes.

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux