# interface cannot extend a non interfaced class?

- Thread: https://externals.io/message/11305
- Original archive: https://news-web.php.net/php.internals/11305
- Started by erik@nordicaudi.com on 2004-07-16T20:31:04+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #11305 — erik@nordicaudi.com — 2004-07-16T20:31:04+00:00

URL: https://externals.io/message/11305#11305

What is the reason for why PHP5 does not allow creating an interface by 
extending a non "interfaced" class?

The follow code produces an error saying "CMAES_Section cannot implement 
CMAES_DB_Section - it is not an interface in <script>"

/Erik

abstract class CMAES_DB_row {
	public funtion bar {
	}
}

class CMAES_DB_Section extends CMAES_DB_row {
	public funtion foo {
	}
}

interface CMAES_Section extends CMAES_DB_Section {
     public function display();
     public function fetchBoards();
}

---

## #11307 — Marcus Boerger — 2004-07-17T00:20:59+00:00

URL: https://externals.io/message/11305#11307 · In reply to: #11305

Hello Erik,

interfaces do not allow code (function bodies) nor doe they allow
properties. But they allow multiple inheritance. That is a class can
inherit multiple interfaces but only one class. The reason for this
is a compromise to overcome the problems with multiple inheritance
namely the pronlem of name conflicts and virtual inheritance versus
normal multiple inheritance. If you need more information on this
you should study computer science in the hope of having one of the
few teacher being able to explain the details or you coule buy some
of the rare books that capture this issue in theory......if not try
to get some experience with c++ and MI.

marcus

Friday, July 16, 2004, 10:31:04 PM, you wrote:

> What is the reason for why PHP5 does not allow creating an interface by 
> extending a non "interfaced" class?

> The follow code produces an error saying "CMAES_Section cannot implement 
> CMAES_DB_Section - it is not an interface in <DEFANGED_script>"

> /Erik

> abstract class CMAES_DB_row {
> 	public funtion bar {
> 	}
> }

> class CMAES_DB_Section extends CMAES_DB_row {
> 	public funtion foo {
> 	}
> }

> interface CMAES_Section extends CMAES_DB_Section {
>      public function display();
>      public function fetchBoards();
> }




-- 
Best regards,
 Marcus                            mailto:helly@php.net
