geudrik Posted November 12, 2010 Share Posted November 12, 2010 http://pastebin.com/DbHQSYd7 Been stumbling my way through OOP and seem to be understanding it for the most part (I think..) But I've got a couple questions / kinks that I can't seem to work out. a) How do I return a variable from a class so that a different class has access to it (meta_data) b) I'm getting a "$this" cannot be redefined error (which I know why, but I don't know how to fix)) c) How do I call a function from within one class, where the function resides in another class, AND pass it variables? Any help would be greatly appreciated I've tried to Google warrior A and I think I can figure that one out, but B and C are proving to be the real stumbling blocks. Quote Link to comment https://forums.phpfreaks.com/topic/218506-oop-variable-passing-function-calls/ Share on other sites More sharing options...
trq Posted November 12, 2010 Share Posted November 12, 2010 a) Create a method which uses return to return the desired data. b) We would need more details before we could help. c) You will need to instantiate that object, then pass it into the object which needs to use it. Looking over your code a little I see the use of the global keyword. This is never a good idea and in particular when attempting to write OOP. It completely breaks the idea of encapsulation and make your code completely un-reusable. Quote Link to comment https://forums.phpfreaks.com/topic/218506-oop-variable-passing-function-calls/#findComment-1133597 Share on other sites More sharing options...
ignace Posted November 12, 2010 Share Posted November 12, 2010 1) I fail to see why you would need 2 classes because this actually should be 1 class. 2) Since you want to support multiple formats (ASX, M3U8, PLS, ..) I would write a class for each. Create a common interface for these classes to implement and declare a function render() in your interface. This class will return what you currently echo() depending on each type. 3) If you tell us more about what you want done we may be able to help you further. Quote Link to comment https://forums.phpfreaks.com/topic/218506-oop-variable-passing-function-calls/#findComment-1133608 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.