Re: Can someone explain ($this->varname) to me..



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.

.