Re: Interface and abstract method

From: Date: Tue, 18 May 2010 15:50:51 +0000
Subject: Re: Interface and abstract method
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-48320@lists.php.net to get a copy of this message
On 18 May 2010 16:12, mathieu.suen <mathieu.suen@easyflirt.com> wrote: > Hi, > > In the SPL there is some interface that have abstract method: > > *Countable* { > /* Methods */ > abstract public int count > <http://www.php.net/manual/en/countable.count.php> > ( void ) > } > > While some interface have "none abstract" method. > > *OuterIterator* extends Iterator > <http://www.php.net/manual/en/class.iterator.php> { > /* Methods */ > public Iterator getInnerIterator > > <http://www.php.net/manual/en/outeriterator.getchildren.php> ( > void ) > ..snip.. > } > > Does  "abstract" keyword have a semantic? > > Thanks > > --Mathieu suen > > > > http://docs.php.net/abstract By the nature of the method being in an interface, it is automatically abstract - there is no code behind the method in an interface. So you must supply the code in any class that implements the interface. Unless the sub-class is declared as an abstract class ... <?php abstract class counter implements countable { } class counting extends counter { public function count() { return 1; } } $a = new counting(); echo $a->count(); ?> -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling

« previous php.internals (#48320) next »