jaikar Posted March 17, 2007 Share Posted March 17, 2007 Hi, i have a doubt about class. i have a class say class A { some codes var $myvar; } class B { $myobject = new A; // here i have the doubt. how i will refer the variable $myvar here is it $myobject->myvar; or $this->$myobject->myvar; or $this->myobject->myvar; } Thanks in advance for your help :-) Jaikar Link to comment https://forums.phpfreaks.com/topic/43122-object-inside-a-class/ Share on other sites More sharing options...
emehrkay Posted March 17, 2007 Share Posted March 17, 2007 $myobject->myvar; Link to comment https://forums.phpfreaks.com/topic/43122-object-inside-a-class/#findComment-209420 Share on other sites More sharing options...
Glyde Posted March 17, 2007 Share Posted March 17, 2007 If you're going to create a reference like that, you should just use: <?php class B extends A { } ?> Then all of A's methods and properties will be available in B Link to comment https://forums.phpfreaks.com/topic/43122-object-inside-a-class/#findComment-209422 Share on other sites More sharing options...
jaikar Posted March 17, 2007 Author Share Posted March 17, 2007 Hi , Thanks for the replies !.... i am not exactly sure about designing a class for a project, i know to write a class, but how ? for now what i am doing is, if i want i will make a new class or if i feel its not needed then i wll put all the functions in one class.. but how to seperate 2 classes, or .. where i will have a need to create 2 new classes ... it took a very long time for me to understand about class .. now i am stilll confused about what will make me to create new classes for a project. Can anyone explain me ?... :-) Thanks ... Jaikar Link to comment https://forums.phpfreaks.com/topic/43122-object-inside-a-class/#findComment-209428 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.