Thanks!
Silly Question -> ( OO Syntax )
Moderator: General Moderators
Silly Question -> ( OO Syntax )
What does -> do in a script?
Thanks!

Thanks!
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
$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
$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
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
To delve deeper... In *very* basic terms a class is a collections of functions:
That syntax would basically give access to the functions in "myClass".
It gets much more advanced if you read up but that's what the syntax you mention is for in any case 
Code: Select all
class myClass {
function a($x) {
return 3*$x;
}
function b($y) {
return 2*$y;
}
}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- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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...)
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...)