I am trying to learn how a specific project works and while I can find most functions online, I found one that stumps me. I see "->" appear every so often in the code, but have no idea what it does. What does "->" mean in PHP or Joomla?
            Asked
            
        
        
            Active
            
        
            Viewed 84 times
        
    -3
            
            
        - 
                    http://www.php.net/manual/en/language.oop5.php – Mark Baker Jan 07 '14 at 22:52
- 
                    http://us1.php.net/manual/en/classobj.examples.php Manual works well. Its the operator that 'points to' an objects methods and parameters. IE a Class object has a parameter named $count. You access that parameter by pointing to it. Class->count – Rottingham Jan 07 '14 at 22:52
- 
                    1Joomla is a system built on PHP, it's not a language by itself. Joomla can't do anything that the underlying PHP it's built in couldn't do already. – Marc B Jan 07 '14 at 22:57
3 Answers
2
            It's the object operator in PHP. It is used to access child properties and methods of classes. Its Javascript and Java equivalent is the . operator. It would be used in PHP like this
class foo{
    public $bar="qux";
    public function display(){
        echo $this->bar;
    }
}
$myFoo=new foo();
$myFoo->display(); //displays "qux"
 
    
    
        scrblnrd3
        
- 7,228
- 9
- 33
- 64
0
            
            
        Its like the . operator in C++ and Java. Refers to members within a class. C++ also uses the -> to access members when the variable preceding the -> is a pointer to a class rather than an instance of the class.
 
    
    
        developerwjk
        
- 8,619
- 2
- 17
- 33
0
            
            
        -> is the way used to call a method.
In C, C++, C#, Java you use . (dot) notation to call a method:
operation.sum(a, b);
In php you do it using ->
operation->sum(a,b)
 
    
    
        Sebastian
        
- 845
- 4
- 12
- 25
- 
                    
- 
                    1you use -> in C++ too when the variable preceding it is a pointer rather than instance – developerwjk Jan 07 '14 at 22:55
 
    