maddogandnoriko Posted March 4, 2009 Share Posted March 4, 2009 I have just recently begun oop programming with php. I am going to write a link verifer for my site that will go through many links and make sure they are valid. My question is....is this better suited for a class or function? For the sake of argument the link list will vary from just one links to many hundreds.... All help is appreciated, Todd Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 4, 2009 Share Posted March 4, 2009 You can do the task using both. If you're trying to learn OOP, then do it OOP way. Quote Link to comment Share on other sites More sharing options...
samshel Posted March 4, 2009 Share Posted March 4, 2009 a function is generally supposed to perform one action. If you have to do multiple actions on a common data set, then classes are prepared. For example: If you have a string and u just have to parse URLs from it, use function. If you have a string and u have to parse URLs, process them, and store statistics in database then write a class which will have function for each action you want to do.. on broader level... function is a piece of code performing an action , which can be reused. Class generally represents an entity. It is a container for properties (member variables) and functions that can be performed on the entity. there is no restriction as such for when u define a function and when u use a class, it depends on your choice ... Quote Link to comment Share on other sites More sharing options...
maddogandnoriko Posted March 4, 2009 Author Share Posted March 4, 2009 Ok. I am trying to learn oop a little better, so I may go that route. Are there any major performance issues? From my point of view, it seems weird using a class to do many things on many variables. To me it seems like it should be a class for each link...which is ridiculous. Is there any downfall of using a class frequently like a function? Todd Quote Link to comment 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.