addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1launch-new-window--smalllight-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

OOP PHP Objects within Objects

From: Will W.
Sent on: Monday, November 12, 2012 8:42 AM
hey guys,  once again I find myself doing something weird with php in command line, but I think its generally applicable to php and oop as a whole so I thought I would ask here.

What I am trying to do is create a manager program to execute programs and have those programs execute functions.

For example,  I am building a currency trader, and what I would like it to do is have my main program call a function within an object, and have that function call another object's function.

So in my main script:


//main program

$object = new object;



and in my middle layer


class object{

$apiHandler = new apihandler;

public function callAwesomness(){



The reason I want to do it this way instead of having one class return an a value and then passing it to the next object is so that I can do it asynchronously.   

Do any of you guys have any insight on this?  This is not working properly, it wont let me instantiate the object within an object.  I know this is bordering the "right language for the right problem" dilemma but I am really trying to focus on just php without other languages creeping onto my resume.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy