讨论数量:
你把变量设置在attributes里面,调用get()方法时会获取到attributes
Symfony\Component\HttpFoundation\Request
public function get($key, $default = null)
{
if ($this !== $result = $this->attributes->get($key, $this)) {
return $result;
}
if ($this !== $result = $this->query->get($key, $this)) {
return $result;
}
if ($this !== $result = $this->request->get($key, $this)) {
return $result;
}
return $default;
}
使用->user_info时调用__get()方法Get an input element from the request. 并不会获取attributes的值
Illuminate\Http\Request
public function __get($key)
{
return Arr::get($this->all(), $key, function () use ($key) {
return $this->route($key);
});
}
你把变量设置在attributes里面,调用get()方法时会获取到attributes
使用->user_info时调用__get()方法Get an input element from the request. 并不会获取attributes的值