[英]PHP Class object syntax that I don't understand
I've inherited a Symfony app and have come across some syntax I've not encountered before: 我继承了一个Symfony应用程序,并且遇到了一些以前从未遇到过的语法:
$data = $request->request->all();
The $request is a HttpFoundation request object. $ request是一个HttpFoundation请求对象。 There is no all() method in the class.
该类中没有all()方法。 The result of the statement is an array w/ all the fields from a submitted form.
该语句的结果是一个数组,其中包含提交表单中的所有字段。
So how do I read the the statement? 那么,我该如何阅读声明? What does the "->request->" mean?
“-> request->”是什么意思?
http://api.symfony.com/3.1/Symfony/Component/HttpFoundation/Request.html http://api.symfony.com/3.1/Symfony/Component/HttpFoundation/Request.html
there is a $request property in that object which is the instance of ParameterBag which has all() 该对象中有一个$ request属性,它是ParameterBag的实例,具有all()
Consider the following as an example: 考虑以下示例:
<?php
class Foo
{
public $bar;
public function __construct()
{
$this->bar = new Bar;
}
}
class Bar
{
public function greet()
{
return 'hello earth';
}
}
$foo = new Foo;
echo $foo->bar->greet();
Output: 输出:
hello earth
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.