NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP 5 Interfaces

Guilherme Blanco guilhermeblanco at gmail.com
Tue May 26 16:05:13 EDT 2009


**ALL** declared methods in an Interface MUST be declared as public.

http://www.php.net/interface

Cheers,

On Tue, May 26, 2009 at 5:02 PM, Joseph Crawford <codebowl at gmail.com> wrote:
> Guys in the past I have used interfaces and have do not recall hitting this
> issue.
> I have the following interface
> <?php
> interface Pagable
> {
> private function getPreviousPage();
> private function getNextPage();
> private function getCurrentPage();
> private function getStartPage();
> private function getLastPage();
> private function getTotalPages();
> public function getPageString();
> public function getTotalResults();
> }
> class YP_Listing_Handler implements Pagable
> {
> ...
> private function getPreviousPage()
> {
> return $this->getCurrentPage() - 1;
> }
> ...
> }
> I keep getting this error.
> Fatal error: Access type for interface method Pagable::getPreviousPage()
> must be omitted in /Applications/MAMP/htdocs/yp/inc/Pagable.php on line 5
>
> I am not sure what is causing it but if I remove the private keyword then it
> complains that it must be declared public in the class.
> Is there a reason I cannot declare a method as being private in the
> interface?
> Thanks,
> Joseph Crawford
>
>
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
>



-- 
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9215-8480
MSN: guilhermeblanco at hotmail.com
URL: http://blog.bisna.com
São Paulo - SP/Brazil



More information about the talk mailing list