ksmatthews Posted August 2, 2009 Share Posted August 2, 2009 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 More sharing options...
trq Posted August 2, 2009 Share Posted August 2, 2009 You can add properties to the stdClass object. $a->foo = 'bar'; print_r($a); but I'm not sure thats what your after. Link to comment https://forums.phpfreaks.com/topic/168490-creating-objects-on-the-stack/#findComment-888822 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.