我可以使用三元运算符的多个条件吗?

问题描述 投票:0回答:0

我想为这个功能:

 echo $this->Html->para(
                    $this->getUser()->isFromEU()
                        ? __d(
                        'Account.account',
                        'accounts.information',
                        [
                            'showButton' => $showButton,
                            'linkToBox' => $pagesInstance->getPage(
                                WWWPages:EU)['url'],
                        ]
                    )
                        : __d(
                        'Account.account',
                        'accounts.help',
                        [
                            'showButton' => $showButton,
                            'linkToBox' => $pagesInstance->getPage(WWWPages::FLL)['url'],
                        ]
                    )
                );

为这个片段添加一个附加条件:

                  : __d(
                        'Account.account',
                        'accounts.help',
                        [
                            'showButton' => $showButton,
                            'linkToBox' => $pagesInstance->getPage(WWWPages::FLL)['url'],
                        ]
                    )
                );

所以我想为这段代码额外添加一个条件。这样的条件:

this.income !== this.result
如果它是真/假那么当然会有另一个带有
__d
的函数片段。

这样一个扩展的三元运算符会是什么样子?

所以如果第一个函数为假,它会转到第二个函数的条件(第二个函数

___d
也有一个条件)并根据其结果,调用满足该条件的函数。

我想知道这样一个运算符的结构是什么样的?

到目前为止它看起来像这样:

$this->getUser()->isFromEU() ? __d(...)[] : __d(...)[]

但是如何扩展到另一个条件呢?

$this->getUser()->isFromEU() ? __d(...)[] : __d(...)[]
<-- And here it should check if
this.income !== this.result
.

php if-statement cakephp
© www.soinside.com 2019 - 2024. All rights reserved.