Page 1 of 1
Silly Question -> ( OO Syntax )
Posted: Tue Jul 19, 2005 11:22 am
by denz
What does -> do in a script?
Thanks!

Posted: Tue Jul 19, 2005 11:28 am
by djot
read about object oriented programming (OOP) on your favorite php website...
Posted: Tue Jul 19, 2005 11:31 am
by shiznatix
$a->c();
$a is a object which is just a reference to a class
-> kinda means like to that which you will understand in 2 seconds
c() is the function within the class
so it goes class to function in class. understand? probebly not, its hard to get the idea but after you figure it out its quite helpful
Posted: Tue Jul 19, 2005 11:41 am
by djot
shiznatix wrote:understand? probebly not
right :)
Posted: Tue Jul 19, 2005 12:54 pm
by Chris Corbyn
To delve deeper... In *very* basic terms a class is a collections of functions:
Code: Select all
class myClass {
function a($x) {
return 3*$x;
}
function b($y) {
return 2*$y;
}
}
That syntax would basically give access to the functions in "myClass".
Code: Select all
$myClass = new myClass; //Hmm... that's called instantiating (making the class ready to use)
$var1 = $myClass->a(4); // 3*4 == 12
$var2 = $myClass->b(1); // 2*1 == 2
It gets much more advanced if you read up but that's what the syntax you mention is for in any case

Posted: Tue Jul 19, 2005 1:24 pm
by RobertGonzalez
The '->' is called a
path name separator.
The OOP section of the PHP Manual talks about the path name separator, what it does and how it works. Just be watchful, going into OOP makes it difficult to return to regular direct script development.
I had asked this question on this forum once before. You can see the thread by
clicking here. Also, there is
another thread on this topic asked at the CodingForums website.
Hope it helps. Enjoy OOP'ing. (Man that sounds bad...)
Posted: Tue Jul 19, 2005 3:12 pm
by Dale
Thanks for this post, as it's teached me a few new things.
Posted: Tue Jul 19, 2005 4:55 pm
by denz
great! thanks for your posts, will give me some more background reading to do and will teach me a thing or two!
Thanks