What does operator -> mean in PHP? [duplicate] - php

This question already has answers here:
Closed 10 years ago.
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?

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?.

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.

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

Related

what is this "->" symbol called name? [duplicate]

This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
Where do we use the object operator "->" in PHP?
(6 answers)
Closed 4 years ago.
What is this -> symbol Called in PHP. I know it can be interpreted as Equal Sign Right Angle Bracket. | can be called Pipe or OR. but my prof was asking the other term to call the -> symbol. It is for assigning a value to a key in array class. does anyone know what this is called?
This is called the Object Operator. It is used to access properties and methods inside a class, where you put the -> symbol after.
Example from the documentation:
<?php
class foo
{
function do_foo()
{
echo "Doing foo.";
}
}
$bar = new foo;
$bar->do_foo();
?>
As you can see, the do_foo() method is located in the foo class. To access the method outside the class, you need to use the -> symbol to access the properties or methods inside the given class.
Information from the PHP documentation:
Within class methods non-static properties may be accessed by using -> (Object Operator): $this->property (where property is the name of the property). Static properties are accessed by using the :: (Double Colon): self::$property. See Static Keyword for more information on the difference between static and non-static properties.

What is the meaning of "$cm->course" in moodle? [duplicate]

This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
Closed 6 years ago.
I am new at PHP and currently now i am working on moodle LMS tool.
I am referring view.php of scorm package and dont know why $cm->course this is used in php.
Please help.
Thanks in Advance
Have a look here
"->" means accessing the $cm object property course
$cm is an object, and course is a variable. Here you can see brief of PHP syntax with objects:
http://php.net/manual/en/language.types.object.php
PHP has two Object Operator namely -> and ::
-> is used when you are trying to call a method on an Instance and / or access an Instance property.
:: is used when you want to call a static method or call a parent
class's version of a method within a child class.
Reference: https://www.codeproject.com/questions/196270/what-is-meant-by-symbol-in-php
Note: I googled your exact question and got this result!
It is "object operator" - T_OBJECT_OPERATOR. It is used to access properties and methods of class on an object.

what does $this->variable mean [duplicate]

This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
Closed 7 years ago.
$this->var
There's a "->" symbol when we call a variable, and i'd like to know what actually does the "->" means. I tried to do some research but the textbook and the internet don't explain this clealy.
Thanks in advance.
PHP has two Object Operator namely -> and ::
-> is used when you are trying to call a method on an Instance and / or access an Instance property.
:: is used when you want to call a static method or call a parent class's version of a method within a child class.

What is the "->" in code? [duplicate]

This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
What is this called in php: -> [duplicate]
(4 answers)
Closed 9 years ago.
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?
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"
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.
-> 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)

what is the difference between $object::$variable and $object->variable [duplicate]

This question already has answers here:
What's the difference between :: (double colon) and -> (arrow) in PHP?
(6 answers)
Closed 8 years ago.
what is the difference between $object::$variable and $object->variable
both of them can be used to achieve the same but creates difference when the class member-variable is static as follows-
$object::$variable :- This syntax allows the static variable to be achieved through the object
But
$object->variable :- This syntax does not allow the static variable to be achieved through the object.
What is the semantic difference between the two?
$object::$variable and $object->variable
above both are are valid for accessing class property.
Only difference is that $object::$variable is used for access static property where as $object->variable is used for accessing property of class from instance.
For more words refer Amal Murali commented question link.
With $object::$variable you refer to the $variable of the class, $object->variable refers to the $variable of a instance of this class.

Categories