MrD
MrD

Reputation: 5086

Accessing variable from within method

Assuming the following class

class test {

public $x = 2;

public testFunction() {

//...

}

}

Is there any way I can access $x from within testFunction()?

Thanks! :)

Upvotes: 0

Views: 45

Answers (1)

juco
juco

Reputation: 6342

Absolutely, simply using $this->x

You may wish to brush up on PHP's OOP principles.

Upvotes: 0

Related Questions