passing property as an arg. to method???

gsingla4u's Avatar, Join Date: Jul 2009
Go4Expert Member
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 ???
johnny.dacu's Avatar, Join Date: Jul 2010
Contributor
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
}