-3

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?

Crashspeeder
  • 4,291
  • 2
  • 16
  • 21
JdR
  • 3
  • 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
  • 1
    Joomla 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 Answers3

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