hi.. i sometimes see "->" in php codes.. what does this do??.. i tried to do some research but i just found out that it has something to do with objects.. nothin else.. the manual on php.net doesn't say anything about it.. anyone???
When used with the array() construct, => is a method for assigning a value to an array index. Take a look at this.
http://www.php.net/manual/en/function.array.php
Oops, I misread your post, not sure what -> is for.
yeah i know the double arrow (=>) but what about the single one (->) .. i want to script a some imap stuff and the example code on php.net for imap_fetch_overview is
if (is_array ($overview )) { reset ($overview); while (list ($key, $val) = each ($overview)) { print $val->msgno . " - " . $val->date . " - " . $val->subject . "\n"; } }
so what does this
$val->date
mean??
Where an object, eg employee, has a property, eg name, then this is referenced by the notation
$employee->name
Some other OO languages use the "." notation (eg employee.name) whereas PHP uses the C++ style "->"
hth
it is used in calling internal methods of classes. as in:
$var = $class->method;
http://www.php.net/manual/en/ref.classobj.php
ok thyanks very much.. helped me alot understanding the code..
It can also be used in mysql like arrays... Instead it returns the results as an object.
$query = "SELECT * FROM table_name"; $result = mysql_query($query); while ($row = mysql_fetch_object($result)) { echo $row -> ID $row ->LastName $row -> etc; }