Online Shopping : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 5 people (80%) answered Yes
Recently 4 of 5 people (80%) answered Yes

Entry

How can you access and set properties or methods from within a class?

Apr 14th, 2009 03:51
roan mke, ha mo, Himanshu Jain,


Within a class,you can access a property or method by combining the 
$this variable and the ->operator:
Class point
      {
      //properties
      var $x = 0;
      var $y = 0;
       //constructor
       function point( $x, $y )
               {
                // calling a method
                 $this->moveTo( $x, $y );
                  }
         // method
         function moveTo( $x ,$y)
                 {
                  //setting properties
                  $this->x = $x;
                  $this->y = $y;
                  }
           }
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com
http://petsomsorg.blogspot.com
http://helsefitness.blogspot.com
http://reisen-london.blogspot.com
http://salutefisica.blogspot.com
http://curaanimalidomestici.blogspot.com
http://sanatatefitness.blogspot.com
http://husdjur1.blogspot.com
http://petscuidados.blogspot.com
--------------------------------------------------------
http://fluge.blogtact.com/
http://flyreiser.blogtact.com/
http://flyvninger.blogtact.com/
http://curagiardino.blogtact.com/
http://curalagravidanza.blogtact.com/
http://zwangerschapzorg.blogtact.com/
http://viaggiolondra.blogtact.com/
http://ideescadeaux.blogtact.com/
http://schoonheidsverzorging.blogtact.com/
http://londenreizen.blogtact.com/
---------------------------------------------------------