On Tue, 17 Feb 2004 15:34:11 +0000, Stephane Drouard wrote:

Hans,

In PHP you are not allowed to explicit overload methods. Ex:

class A {
        function x($a1) {}
        function x($a1, $a2) {}
}

The function "x" is already defined and explicit overloading is not
possible, so the code above will result in parser error.

In PHP you are allowed to do overriding. The code you supplied:
> class A {
>     function init() { ... }
>     function doSomething($arg1, $arg2) { ... }
> }
>
> class B extends A {
>     function doSomething($arg1, $arg2, $arg3, $arg4 = null) { ... }
>     function doSomethingElse($arg1) { ... }
> }

You are redefining the function doSomething at the child and this is
"overriding".

But when you use an interface, you are telling PHP that you class has a
commitment to implement some functions(signatures).

Since you agreed at the commitment, you can't break it doing
overriding(with a different signature - arguments). The only way is
overloading, but PHP doesn't support it(you can do overloading with
__call, __get and __set but that's not the case).

BTW, overriding with default arguments will be a nice feature.

Cristiano Duarte

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to