Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   passing property as an arg. to method??? (http://www.go4expert.com/forums/passing-property-arg-method-t22882/)

gsingla4u 31Jul2010 08:55

passing property as an arg. to method???
 
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 4Aug2010 23:28

Re: passing property as an arg. to method???
 
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
}




All times are GMT +5.5. The time now is 19:48.