Page 1 of 1

Whats this?

Posted: Tue Dec 24, 2002 1:31 am
by n00b
I'm reading through the PHP manual. I'm fairly good at PHP, but i never read te manual i learnt from viewing.

I've come across this in the PHP manual, dont know what it is:

class foo
{
var $foo;
var $bar;

function foo()
{
$this->foo = 'Foo';
$this->bar = array('Bar1', 'Bar2', 'Bar3');
}
}


What does $this-> mean? What does the -> mean?

Thanks.

Posted: Tue Dec 24, 2002 1:36 am
by n00b
and this:

array("foo" => "bar", 12 => true);


whats => ?

Posted: Tue Dec 24, 2002 2:43 am
by EricS
this-> is a special construct that means use the variable I've defined within THIS class.

Posted: Tue Dec 24, 2002 10:35 am
by mydimension
the => is used to relate a key with a vlaue in an array. i.e.:

$arr = array("foo" => "bar", 12 => true);

you now can do this:

print $arr['foo']; //outputs bar

print $arr[12]; //outputs 1 - the numerical equivilant to TRUE