public function user(request $request){}
回复内容: public function user(request $request){}
http://php.net/manual/zh/language.oop5.typehinting.php
php 5 可以使用类型约束。
函数的参数可以指定必须为对象(在函数原型里面指定类的名字),接口,数组(php 5.1 起)或者 callable(php 5.4 起)。
官方例子
/** * 测试函数 * 第一个参数必须为 otherclass 类的一个对象 */ public function test(otherclass $otherclass) { echo $otherclass->var; }
request就是一个类,$request就是它生成的一个对象!当然啦,也可以是接口之类的!