NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP 5 Interfaces

Joseph Crawford codebowl at gmail.com
Tue May 26 16:02:53 EDT 2009


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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090526/b519243d/attachment.html>


More information about the talk mailing list