In PHP 5, abstract methods are marked with abstract keywords, and classes containing abstractions are abstract classes and must be marked with abstract.
? PHP
Abstract class AbstractClass {
Abstract Public function test ();
}
class Implementedclass extends AbstractClass {
Public function Test () {
Echo " implementedclass::test () called. " ;
}
}
$o = New Implementedclass;
$o -> test ();
?>
PHP 5 also supports the concept of interfaces and introduces the interface and implements keywords. Like Java, PHP 5 uses interfaces to achieve a "multiple inheritance" effect. The syntax is as follows:
? PHP
Interface displayable {
function display ();
}
Interface Printable {
function Doprint ();
}
class Foo Implements displayable , Printable {
function display () {
// Code
} function Doprint () {
// Code
}
}
?>
The introduction of abstract classes and interfaces makes PHP a fully object-oriented language. One more thing: this kind of syntax and Java is so much like.
</