ignace Posted September 29, 2006 Share Posted September 29, 2006 Hey after some googling and reading, have i come to a certain page in my life, that i got stuck! I'm a huge fan of normalisation (it makes atleast my life a bit easier) so now am i trying to do this also on some oop (object oriented programming - for those who do not know what i mean)So if interface, implements, extends, etc... is no foreign language for you, then please feel free to be so kind and enlight my mind... xDThanx in advance,Ignace Quote Link to comment https://forums.phpfreaks.com/topic/22520-oop-some-questions-regarding-final-interface-implements-extends/ Share on other sites More sharing options...
Barand Posted September 29, 2006 Share Posted September 29, 2006 This may help with some of the questions.http://www.phpfreaks.com/forums/index.php/topic,104878.0.htmlAn interface is similar to a parent class except it has no code defined in it, just a list of method declarations which the implementing class must define. Quote Link to comment https://forums.phpfreaks.com/topic/22520-oop-some-questions-regarding-final-interface-implements-extends/#findComment-101016 Share on other sites More sharing options...
Jenk Posted September 29, 2006 Share Posted September 29, 2006 an interface provides rules for an objects relational accessibility (i.e. interface)Much like USB has a certain shape to it's plugs, a class interface defines the access points.Abstract classes are simply parent classes that must be extended in order to use them. You can specify abstract methods that must be overloaded by the child class, whilst also maintaining common functionality amongst those child classes within the parent abstract class.Classes can only extend one parent, but can implement many interfaces.Final is the opposite of abstract. It cannot be overloaded/extended. Quote Link to comment https://forums.phpfreaks.com/topic/22520-oop-some-questions-regarding-final-interface-implements-extends/#findComment-101033 Share on other sites More sharing options...
ignace Posted September 29, 2006 Author Share Posted September 29, 2006 thx for the information, @barand so an interface is much like the prototypes that you can define in c++? but now you use a child class to implement them instead of adding them after [ int main(); ] Quote Link to comment https://forums.phpfreaks.com/topic/22520-oop-some-questions-regarding-final-interface-implements-extends/#findComment-101042 Share on other sites More sharing options...
Barand Posted September 29, 2006 Share Posted September 29, 2006 Slightly different emphasis. Prototypes tell you what is defined, interface tells what [b]must be[/b] defined for the class to function correctly Quote Link to comment https://forums.phpfreaks.com/topic/22520-oop-some-questions-regarding-final-interface-implements-extends/#findComment-101046 Share on other sites More sharing options...
ignace Posted September 30, 2006 Author Share Posted September 30, 2006 k, thx, now something else, overloading is this done in the same way as in c++?string doMyHomework(string Input);string doMyHomework(double Input);however i can not define the return type or the argument typefunction doMyHomework($Input);function doMyHomework($Input); // cannot redeclare function 'doMyHomework'so how do i overload a php function? Quote Link to comment https://forums.phpfreaks.com/topic/22520-oop-some-questions-regarding-final-interface-implements-extends/#findComment-101334 Share on other sites More sharing options...
Barand Posted September 30, 2006 Share Posted September 30, 2006 As php isn't a strongly typed language like C it doesn't really apply.[code]<?phpfunction doubleMe ($input) { return $input * 2;}$x = "2"; // string$y = 2.75; // float$z = 3; // intecho doubleMe($x);echo '<br/>';echo doubleMe($y);echo '<br/>';echo doubleMe($z);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22520-oop-some-questions-regarding-final-interface-implements-extends/#findComment-101589 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.