Page 1 of 1
been around the block...
Posted: Sun Jun 06, 2004 8:55 pm
by dull1554
i have been around for a bit and have never used the "->" operator or whatever it is
i tried searching this forum and google and the manual but cant really see anything at all about it
was wondering if someone more knowledgable then myself could explain it and maybe show an example
(also i've seen it used with a foreach statement, and have no clue what either is for)
Posted: Sun Jun 06, 2004 9:05 pm
by launchcode
Do you mean like this: $something->else ?
It's just a way of calling a function inside an object. In the instance above, the function "else" from the object "something". If you look in the PHP manual in the objects/classes section you'll see it used all over the place

Posted: Sun Jun 06, 2004 9:07 pm
by dull1554
ok
thanks a bunch, never thought to look there
that helps a great deal
Posted: Sun Jun 06, 2004 10:37 pm
by andre_c
What you see in a foreach is actually this =>. Look into associative arrays to understand it.
( maybe you did see this -> in a foreach and i'm just assuming wrong )
Posted: Mon Jun 07, 2004 2:36 am
by qads
Code: Select all
<?php
for($x = 0; $x <= $bla->num(); $x++)
{
echo $x."<br />";
}
?>
could've been something like above ^^.
Posted: Mon Jun 07, 2004 8:38 am
by dull1554
i understand it all, its classes and all, i had never really looked into any such thing
but yes i have seen something like that where $bla is initiated with the new command and -> tells it that you want a certain function out of that class..