Page 1 of 1

what is this thing: ->

Posted: Tue Jun 19, 2007 11:08 pm
by batcloud
Dumb question:
There is a piece of code that I want to modify. But I keep coming across the operator ->
What is it? Google search does not return anything sensible, probably because it ignores those characters. Same with devNet searches, php dot net. I am sure it is a simple thing, but I don't know php. Is it some kind of value assignment? Or is it passing values?
For example in:
return $this->data['title'];
what is the operator that comes after $this
Thanks

Posted: Tue Jun 19, 2007 11:15 pm
by superdezign
The "->" operator (in PHP) is how you access an object's functions and attributes.

Code: Select all

$result = mysql_query($query);
$object = mysql_fetch_object($result);

echo $object->data;

Using it with the $this keyword implies that you are working within a class.

Posted: Tue Jun 19, 2007 11:22 pm
by feyd
If you search my posts for threads where I said "deref*" you'll find answers. :)

Posted: Wed Jun 20, 2007 12:02 am
by batcloud
Summary of what I found:

T_OBJECT_OPERATOR is a parser token whose syntax is ->
Pronounced "deref", short for dereference.
More information may be available where ever classes and objects are discussed.

Thanks feyd, superdezign, timvw !