Reputation: 21
Hello guys I've looking on many php scripts and I saw something like this
$variable->function($var1, $var2, $var3)
So what does this ->
exactly do ?
and thank you.
Upvotes: 0
Views: 145
Reputation: 12988
A more generic info at Wikipedia: Object Oriented Programming
I don't think it is a good idea to give a direct answer, like the others already did but to give a link to the topic itself since without the background, most of the answers won't make much sense.
Upvotes: 1
Reputation: 6355
The -> access a function within the $variable's class. So a $variable might be an instance of a class like,
$variable = new Person();
$variable->showFirstName();
and in class Person, there would be a function
function showFirstName() {
echo $this->$first_name;
}
Upvotes: 0
Reputation: 17553
It calls a method on an object. But to understand what that means, you need to understand object-oriented programming in PHP. The manual is extremely good, read it here:
http://php.net/manual/en/language.oop5.php
Upvotes: 1
Reputation: 21466
It implies $variable is an object, and is calling the "function" method of the object assigned to $variable.
Upvotes: 0
Reputation: 6131
its a function call on an object
Object-Variable: $variable
Call: ->
Function: function(...)
Upvotes: 7