问候!我不想了解更多关于抽象类和接口的信息。和术语继承,如抽象类扩展和接口实现。需要帮助。请解决我的问题。提供一些例子。
问问题
86 次
1 回答
0
抽象类是未实例化的类,因此不存在这样的事情:
<?php
$p = new person();
?>
抽象类只能被继承,不能直接使用。您将它用作基类,您可以在其中放置其他类可以共享的所有代码。
接口就像一个类必须实现的方法的协议:
// Declare the interface 'iExample'
interface iExample
{
// methodes
}
// Implement the interface
// This will work
class Thingy implements iExample
{
// implement the methodes specifies in the interface
}
于 2012-04-12T15:39:08.890 回答