php模仿go实现多变量返回

php模仿go实现多变量返回,第1张

概述2021年5月25日18:40:56环境php8.0.3classIndexOpenControllerextendsBaseController{publicfunctiontest(Request$request){[$t1,$u1]=$this->zx();p($t1);p($u1);}publicfunctionzx(){$t=2

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

 

总结

以上是内存溢出为你收集整理的php模仿go实现多变量返回全部内容,希望文章能够帮你解决php模仿go实现多变量返回所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/langs/1001310.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存