abstract class SF_Model_Acl_Abstract
extends SF_Model_Abstract
implements SF_Model_Acl_Interface, Zend_Acl_Resource_Interface
{
protected $_acl;
protected $_identity;
public function setIdentity($identity)
{
if (is_array($identity)) {
......
......
Can you help me explain how it can "implements
" "extends
" at the same time?
Does it just combine the 3 class together?
I am totally confused!
extends
is for inheritance, i.e. inheriting the methods/fields from the class. A PHP class can only inherit from one class.
implements
is for implementing interfaces. It simply requires the class to have the methods which are defined in the implemented interfaces.
Example:
interface INamed { function getName($firstName); }
class NameGetter { public function getName($firstName) {} }
class Named implements INamed { function getName($firstName) {} }
class AlsoNamed extends NameGetter implements INamed {}
class IncorrectlyNamed implements INamed { function getName() {} }
class AlsoIncorrectlyNamed implements INamed { function setName($newName) {} }
This code throws a fatal error in line 5 as a method from the interface is not properly implemented (argument missing). It would also throw a fatal error in line 6 as the method from the interface is not implemented at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With