运算符 -> 在 PHP 中是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10585149/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 22:31:31  来源:igfitidea点击:

What does operator -> mean in PHP?

php

提问by Bruno

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

可能的重复:
PHP 语法 $var1->$var2 是什么意思?
参考 - 这个符号在 PHP 中是什么意思?

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

我正在查看 PHP 框架的代码,时不时会出现符号“->”……例如:

$controller->permissionCheck($ret);

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

“->”代表什么,用于什么?

回答by GDP

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

在您的示例中,$controller是在某处创建的 PHP 对象,permissionCheck 是在该对象中定义的函数,该函数$ret正在通过传递给它的变量进行调用。检查这个:参考 - 这个符号在 PHP 中是什么意思?.

回答by bjornruysen

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.

它用于寻址类的函数或属性。在这种情况下,似乎调用了控制器类的函数。

回答by Denis Ermolin

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

运算符->用于访问$controller对象的非静态成员。在您的情况下,成员是 function permissionCheck