I've been looking around for this but can someone please enlighten me as to what the '->' operator does?
Such as
$var1 -> $var2
Thanks.
$class->variable
or
$class->function()
is part of classes and how to get variables and functions within them.
This operator references a member variable of function/method of a class instance.
E.g: $object->var $object->function_call()
Outside of classes, I have also seen this syntax when using the mysql_fetch_object() function:
PHP.net wrote: <?php mysql_connect("hostname", "user", "password"); mysql_select_db("mydb"); $result = mysql_query("select * from mytable"); while ($row = mysql_fetch_object($result)) { echo $row->user_id; echo $row->fullname; } mysql_free_result($result); ?>
<?php mysql_connect("hostname", "user", "password"); mysql_select_db("mydb"); $result = mysql_query("select * from mytable"); while ($row = mysql_fetch_object($result)) { echo $row->user_id; echo $row->fullname; } mysql_free_result($result); ?>