Posted by raghuanandy@gmail.com on 01/13/07 12:06
Manfred Kooistra wrote:
> I have these pieces of example code that I am trying to figure out:
>
> (a) $a = $b->c();
> (b) $d->e();
>
> What does "->" do?
Basically, "->" use to reference variables or functions (or more
precisely members and methods) within a class.
eg:
class Something {
public $a = 'Hello';
function __construct($a)
{ $this->a = $a; }
function SetA($a);
{ $this->a = $a; }
function GetA()
{ return $this->a; }
} //end class
Now the member "a" and methods SetA , GetA can be accessed via the "->"
operator
$obj = new Something('World');
//Access method "GetA" of object "obj" using ->
print $obj->GetA();
//accessing member "a" of object "obj" using ->
$obj->a = 'Hello';
print $obj->a;
> Where is there a reference/explanation in the PHP manual (or anywhere
> else)?
>
> (Unfortunately Google et al. don't search for these characters, so I
> don't know how to look for an explanation on this.)
For more information visit:
http://www.php.net/manual/en/language.oop.php
&
http://www.php.net/manual/en/language.oop5.basic.php
Navigation:
[Reply to this message]
|