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]; } }