Home  >  Article  >  Backend Development  >  What does Request $request mean?

What does Request $request mean?

WBOY
WBOYOriginal
2016-08-04 09:21:372467browse

public function User(Request $request){}

Reply content:

public function User(Request $request){}

http://php.net/manual/zh/language.oop5.typehinting.php

PHP 5 can use type constraints.
The parameters of the function can be specified to be objects (specify the class name in the function prototype), interfaces, arrays (from PHP 5.1) or callable (from PHP 5.4).

Official example

<code>    /**
     * 测试函数
     * 第一个参数必须为 OtherClass 类的一个对象
     */
    public function test(OtherClass $otherclass) {
        echo $otherclass->var;
    }</code>

Request is a class, and $request is an object generated by it! Of course, it can also be an interface or something like that!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn