Re: About PHP Implements

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

 



On Dec 18, 2007 4:58 PM, Jim Webber <webber@xxxxxxxxxxxxxxx> wrote:
> Hello I have a PHP4 server and I'm trying to figure out how to do
> "implements" on classes. Is there an analogous way to do this without
> PHP5 installed?
>

It isn't inheritance in the same sense as PHP5, but you can use the
method_exists() function to check whether a given object has the
method you want to use before you try to use it.

if (method_exists($obj, 'doSomething')) {
    $obj->doSomething();
} else {
    // $obj does not support the required interface
}

This at least allows a way for your code to enforce the interface on
an as-needed basis and recover gracefully.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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