Connecting Tech Pros Worldwide Forums | Help | Site Map

java or PHP 5.0 question about interfaces

lawrence
Guest
 
Posts: n/a
#1: Jul 17 '05
Do interfaces enforce how many arguments can be passed to a method? If
two classes inherit from the same interface, can one have
formatThisText($text) and another have formatThisText($text,
$formatter) ??? I'm assuming the answer is yes, interfaces do enforce
the number of arguments.

Fabian Wleklinski
Guest
 
Posts: n/a
#2: Jul 17 '05

re: java or PHP 5.0 question about interfaces


Hi Lawrence,
[color=blue]
> I'm assuming the answer is yes, interfaces do enforce
> the number of arguments.[/color]

Concerning JAVA you are right. Interface enforce the number
of parameters, their types, the type of the returned value
and even the method's visibility.

Greetings From Frankfurt/Germany,

Fabian Wleklinski


lawrence
Guest
 
Posts: n/a
#3: Jul 17 '05

re: java or PHP 5.0 question about interfaces


lkrubner@geocities.com (lawrence) wrote in message news:<da7e68e8.0310140020.ff5df7e@posting.google.c om>...[color=blue]
> Do interfaces enforce how many arguments can be passed to a method? If
> two classes inherit from the same interface, can one have
> formatThisText($text) and another have formatThisText($text,
> $formatter) ??? I'm assuming the answer is yes, interfaces do enforce
> the number of arguments.[/color]

Thank you for the reply. That is what I would expect in Java. Does
anyone know the answer for PHP 5.0? Or where that information is
documented? I noticed a bunch of very interesting articles here
(though they didn't answer my question):

http://www.zend.com/zend/php5/index.php

PHP is truly become a script version of Java, with a nearly complete
imitation of Java's object features, minus strict typing.

Still, I'm wondering about interface enforcement in PHP 5.0 and can't
find an answer.

Another question I have is can an argument passed to a method have a
default value in one object but a different default value, or none, in
another object if both inherit from the same interface?
Closed Thread