Loading ...
Sorry, an error occurred while loading the content.

Re: [phpXperts] Class wondering???

Expand Messages
  • lucasPirola
    wow everybody, ... i think so, its no good ideia, get value of a variable s class, like that, i think its better you create a getter, like this: public
    Message 1 of 12 , Feb 3, 2006
    • 0 Attachment
      wow everybody,

      > On 2/3/06, Aniruddha Deshpande <solofone@...> wrote:
      > $obj->fname(10); // it will send 10 to $var2 in function f_name
      > now you can access the var1 like
      > echo $obj->var1;

      i think so, its no good ideia, get value
      of a variable's class, like that,
      i think its better you create a getter,
      like this:

      public function getVariable() {
      return $this->var1;
      }

      fix me, if i wrong!!!!

      --
      webDeveloper
      ------------------------------------------------------------
      icq->254902
      msn->lucaspirola@...
    • Jim Mullen
      What are the advantages of using a getter function? The one disadvantage I see is the overhead of having to execute a function when you could just get access
      Message 2 of 12 , Feb 3, 2006
      • 0 Attachment
        What are the advantages of using a "getter" function?  The one disadvantage I see is the overhead of having to execute a function when you could just get access the class property (i.e. variable) directly.

        Best regards,
        Jim at iDimensionz.com

        --
        http://www.iDimensionz.com  Professional web site design and affordable web site hosting.

        Get Firefox! – Get the new open source web browser, FireFox, and enjoy features like pop up blocking, tabbed browsing and MUCH more!
        Get Thunderbird! – Get the new open source e-mail client, ThunderBird, and enjoy features like integrated spam filter, privacy protection, integrated RSS reader and MUCH more!


        lucasPirola wrote:
        wow everybody,

        > On 2/3/06, Aniruddha Deshpande <solofone@...> wrote:
        > $obj->fname(10); // it will send 10 to $var2 in function f_name
        > now you can access the var1 like
        > echo $obj->var1;

        i think so, its no good ideia, get value
        of a variable's class, like that,
        i think its better you create a getter,
        like this:

        public function getVariable() {
          return $this->var1;
        }

        fix me, if i wrong!!!!

        --
        webDeveloper
        ------------------------------------------------------------
        icq->254902
        msn->lucaspirola@...

      • lamy_ici
        no need to put public, this will do function getVariable() { return $this- var1; }
        Message 3 of 12 , Feb 3, 2006
        • 0 Attachment
          no need to put public, this will do

          function getVariable()
          {
          return $this->var1;
          }

          --- In phpexperts@yahoogroups.com, lucasPirola <lucaspirola@...>
          wrote:
          >
          > wow everybody,
          >
          > > On 2/3/06, Aniruddha Deshpande <solofone@...> wrote:
          > > $obj->fname(10); // it will send 10 to $var2 in function f_name
          > > now you can access the var1 like
          > > echo $obj->var1;
          >
          > i think so, its no good ideia, get value
          > of a variable's class, like that,
          > i think its better you create a getter,
          > like this:
          >
          > public function getVariable() {
          > return $this->var1;
          > }
          >
          > fix me, if i wrong!!!!
          >
          > --
          > webDeveloper
          > ------------------------------------------------------------
          > icq->254902
          > msn->lucaspirola@...
          >
        • lucasPirola
          ... disadvantage I see is the overhead of having to execute a function when you could just get access the class property (i.e. variable) directly. well, you
          Message 4 of 12 , Feb 3, 2006
          • 0 Attachment
            On 2/3/06, Jim Mullen <jim@...> wrote:
            >What are the advantages of using a "getter" function? The one
            disadvantage I see is the overhead of having to execute a function
            when you could just get access the class property (i.e. variable)
            directly.

            well, you are rigth but, when
            you use object oriented and
            some patterns.. i guess this is
            very usefull.. like when you use:
            public, protect and private members
            you see here [1][2].
            But, fix me if this is wrong!!!!

            [1] http://www.developer.com/open/article.php/10930_3302171_1
            [2] http://www.phppatterns.com/docs/design/guidelines_for_designing_classes_in_php

            See you

            --
            webDeveloper
            ------------------------------------------------------------
            icq->254902
            msn->lucaspirola@...
          • lucasPirola
            oh yeah, sorry, you are rigth, but protect and private wiil be good.. i think so!! see you... ... -- webDeveloper ... icq- 254902 msn- lucaspirola@msn.com
            Message 5 of 12 , Feb 3, 2006
            • 0 Attachment
              oh yeah,

              sorry, you are rigth,
              but protect and private wiil be good..
              i think so!!

              see you...

              On 2/3/06, lamy_ici <lamy_ici@...> wrote:
              > no need to put public, this will do
              >
              > function getVariable()
              > {
              > return $this->var1;
              > }
              >
              > --- In phpexperts@yahoogroups.com, lucasPirola <lucaspirola@...>
              > wrote:
              > >
              > > wow everybody,
              > >
              > > > On 2/3/06, Aniruddha Deshpande <solofone@...> wrote:
              > > > $obj->fname(10); // it will send 10 to $var2 in function f_name
              > > > now you can access the var1 like
              > > > echo $obj->var1;
              > >
              > > i think so, its no good ideia, get value
              > > of a variable's class, like that,
              > > i think its better you create a getter,
              > > like this:
              > >
              > > public function getVariable() {
              > > return $this->var1;
              > > }
              > >
              > > fix me, if i wrong!!!!
              > >
              > > --
              > > webDeveloper
              > > ------------------------------------------------------------
              > > icq->254902
              > > msn->lucaspirola@...
              > >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              > Visit phpXperts website at www.phpxperts.com
              > Yahoo! Groups Links
              >
              >
              >
              >
              >
              >
              >


              --
              webDeveloper
              ------------------------------------------------------------
              icq->254902
              msn->lucaspirola@...
            • Aniruddha Deshpande
              Hi lucas, You are right. Class methods are right way to manuplate the class members data. If you had worked in Java or c++ it strongly recommands that. But in
              Message 6 of 12 , Feb 4, 2006
              • 0 Attachment
                Hi lucas,
                You are right. Class methods are right way to manuplate the class members data.

                If you had worked in Java or c++ it strongly recommands that.
                But in php i also didn't get any documentation for opps suporting concepts in php.
                So i just gave what i have seen in many projects i handled.

                Thanks for giving clear idea.

                On 2/3/06, lucasPirola < lucaspirola@...> wrote:
                wow everybody,

                > On 2/3/06, Aniruddha Deshpande <solofone@...> wrote:
                > $obj->fname(10); // it will send 10 to $var2 in function f_name
                > now you can access the var1 like
                > echo $obj->var1;

                i think so, its no good ideia, get value
                of a variable's class, like that,
                i think its better you create a getter,
                like this:

                public function getVariable() {
                  return $this->var1;
                }

                fix me, if i wrong!!!!

                --
                webDeveloper
                ------------------------------------------------------------
                icq->254902
                msn->lucaspirola@...





                Visit phpXperts website at www.phpxperts.com



                SPONSORED LINKS
                Programming languages Php coder Knowledge base
                Computer security C programming language Computer programming languages


                YAHOO! GROUPS LINKS






                --
                Thanx
                Brest Regards
                Aniruddha Deshpande
              • lamy_ici
                sorry, i should have mentioned that you can also use those, and itll be a better practice ;) ... f_name
                Message 7 of 12 , Feb 4, 2006
                • 0 Attachment
                  sorry, i should have mentioned that you can also use those, and itll
                  be a better practice ;)

                  --- In phpexperts@yahoogroups.com, lucasPirola <lucaspirola@...>
                  wrote:
                  >
                  > oh yeah,
                  >
                  > sorry, you are rigth,
                  > but protect and private wiil be good..
                  > i think so!!
                  >
                  > see you...
                  >
                  > On 2/3/06, lamy_ici <lamy_ici@...> wrote:
                  > > no need to put public, this will do
                  > >
                  > > function getVariable()
                  > > {
                  > > return $this->var1;
                  > > }
                  > >
                  > > --- In phpexperts@yahoogroups.com, lucasPirola <lucaspirola@>
                  > > wrote:
                  > > >
                  > > > wow everybody,
                  > > >
                  > > > > On 2/3/06, Aniruddha Deshpande <solofone@> wrote:
                  > > > > $obj->fname(10); // it will send 10 to $var2 in function
                  f_name
                  > > > > now you can access the var1 like
                  > > > > echo $obj->var1;
                  > > >
                  > > > i think so, its no good ideia, get value
                  > > > of a variable's class, like that,
                  > > > i think its better you create a getter,
                  > > > like this:
                  > > >
                  > > > public function getVariable() {
                  > > > return $this->var1;
                  > > > }
                  > > >
                  > > > fix me, if i wrong!!!!
                  > > >
                  > > > --
                  > > > webDeveloper
                  > > > ------------------------------------------------------------
                  > > > icq->254902
                  > > > msn->lucaspirola@
                  > > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > > Visit phpXperts website at www.phpxperts.com
                  > > Yahoo! Groups Links
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  >
                  >
                  > --
                  > webDeveloper
                  > ------------------------------------------------------------
                  > icq->254902
                  > msn->lucaspirola@...
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.