I come from a VB background, so encountered the same problem.
In VB you would create a class like this: -
Code:
Public intLength as integer
Public intHeight as integer
public function Area() as integer
Area=intLength*intHeight
End function
In VB, if you are within a function of a class and want to reference a class variables within the same class, then you would just invoke the variable name ([tt][blue]Area=intLength*intHeight[/blue][/tt]).
However in PHP, you need to use different syntax: -
Code:
var $Length;
var $Height;
function Area() {
return $this->Length*$this->Height;
}
In PHP syntax, the class level variable will lose its [tt][blue]$[/blue][/tt] and be post-fixed instead by [tt][blue]$this->[/blue][/tt]. This also holds true when referencing any function of a class externally.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.