Re: Can someone explain ($this->varname) to me..
- From: 4sak3n 0ne <4sak3n0ne@xxxxxxxxx>
- Date: Fri, 31 Aug 2007 10:52:24 -0700
On Aug 31, 10:44 am, stiki <lapto...@xxxxxxxxx> wrote:
How and what does this mean in php: ($this->varname)
I can't seem to find this by searching Google, because the "->" are
removed from my search query.
Cheers,
Igor Terzicwww.stikimedia.com
-> is used when referring to a classes inner workings. $this is a
special variable used within a class to refer to itself.
Example:
----------------------------------------
class Example{
var $classVariable = "Something";
function testFunction(){
echo "I'm just a simple function.";
}
function show(){
$this->testFunction();
}
}
$c = new Example;
$c->testFunction(); // Returns I'm just a simple function.
$c->show(); // Returns I'm just a simple function.
echo $c->classVariable; // Returns Something
------------------------------------------
Hope that clears thing up for you.
.
- References:
- Can someone explain ($this->varname) to me..
- From: stiki
- Can someone explain ($this->varname) to me..
- Prev by Date: Re: PHP and .NET
- Next by Date: Re: Can someone explain ($this->varname) to me..
- Previous by thread: Can someone explain ($this->varname) to me..
- Next by thread: Re: Can someone explain ($this->varname) to me..
- Index(es):