0

Possible Duplicates:
What does the PHP syntax $var1->$var2 mean?
Reference - What does this symbol mean in PHP?

I'm looking at a PHP framework's code, and now and then the symbols "->" appear... for example:

$controller->permissionCheck($ret);

What does "->" stand for and what is used for?

Community
  • 1
  • 1
Bruno
  • 403
  • 2
  • 4
  • 12

3 Answers3

5

In your example, $controller is a PHP object created somewhere, and permissionCheck is a function defined in that object that is being called with the variable $ret being passed to it. Check this: Reference - What does this symbol mean in PHP?.

Community
  • 1
  • 1
GDP
  • 7,641
  • 6
  • 40
  • 73
  • so I'm setting a value to permissionCheck($ret) that is given by $controller ? so, basically, it's a more elaborated way to assign a value to permissionCheck($ret) ? – Bruno May 22 '12 at 23:10
  • Possibly, but not necessarily. Controller is an object, and contained within it is a function called permission check. That function could contain a dozen calls to a database that are also in that object , or a call to an opened API. So, in short, you're not assigning a value to anything - you are passing a value to a function. – GDP May 23 '12 at 03:29
1

It's used to address a function or property of a class. In this case a function of the controller class seems to be called.

bjornruysen
  • 850
  • 1
  • 6
  • 15
1

Operator -> is for access to the non-static members of $controller object. In your case, the member is the function permissionCheck.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Denis Ermolin
  • 5,330
  • 5
  • 25
  • 41