passing property as an arg. to method???

Go4Expert Member
31Jul2010,08:55   #1
gsingla4u's Avatar
guys how to pass a property as an argument/parameter to a method in same class.
Coz i think this is not valid:


Code:
class A{
             public $var=4;
       function xyz($this->var){      // invalid way.
           
       }
}
so is there a way that i can actually pass property to a method ???
Contributor
4Aug2010,23:28   #2
johnny.dacu's Avatar
Well if you want to use a class property in a method use something like this:
PHP Code:
class A{
public 
$var 4;
public function 
xyz(){
$this->var //here you use your variable
}