php模仿go实现多变量返回
2021年5月25日18:40:56
环境php8.0.3
class IndexOpenController extends BaseController { public function test(Request $request) { [$t1, $u1] = $this->zx(); p($t1); p($u1); } public function zx() { $t = 22; $u = 33; return [$t, $u]; } }
是从PhpSpreadsheet源代码看到写法,代码方便一些
更多返回
class IndexOpenController extends BaseController { public function test(Request $request) { [$u1, $u2, $u3] = $this->zx(); p($u1); p($u2); p($u3); } public function zx() { $t1 = 22; $t2 = 33; $t3 = 44; return [$t1, $t2, $t3]; } }
只接受部分
class IndexOpenController extends BaseController { public function test(Request $request) { [$u1, $u2] = $this->zx(); p($u1); p($u2); // p($u3); } public function zx() { $t1 = 22; $t2 = 33; $t3 = 44; return [$t1, $t2, $t3]; } }
QQ一群 247823727
QQ二群 166427999
博客文件如果不能下载请进群下载
如果公司项目有技术瓶颈问题,请联系↓↓
如果需要定制系统开发服务,请联系↓↓
技术服务QQ: 903464207
QQ二群 166427999
博客文件如果不能下载请进群下载
如果公司项目有技术瓶颈问题,请联系↓↓
如果需要定制系统开发服务,请联系↓↓
技术服务QQ: 903464207