Jump to content

object inside a class


jaikar

Recommended Posts

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

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

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.