What does Request $request mean?

WBOY
Release: 2016-08-04 09:21:37
Original
2510 people have browsed it

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>
Copy after login

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template