Jump to content

creating objects on the stack


ksmatthews

Recommended Posts

Hi There,

 

In languages like java and C++ you can create objects on the fly as class variables, like this ...

 

class myClass

{

  // Declare class members here

  private class1 myobj;

  private class2 myobj2;

  private class3 myobj3;  // etc

 

  // constructor

  public function myClass(){}

 

  public function fred()

  {

    myobj.function1();

    myobj2.function2();

 

  // etc

  }

}

 

Can you do this in PHP 5 without using new and  if so , how ?

 

regards,

 

Steven M

 

Link to comment
https://forums.phpfreaks.com/topic/168490-creating-objects-on-the-stack/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.