Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/218506-oop-variable-passing-function-calls/
Share on other sites

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.