been around the block...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

been around the block...

Post 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)
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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 :)
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

ok
thanks a bunch, never thought to look there
that helps a great deal
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post 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 )
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

Code: Select all

<?php
for($x = 0; $x <= $bla->num(); $x++)
{
echo $x."<br />";
}
?>
could've been something like above ^^.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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..
Post Reply