Home > Net >  for which server ? and : without php
for which server ? and : without php

Time:01-13

I have the following scenario

I have an api where there is an array of data

                $loyaltyData ?? [],
                [
                    'type'                  => $this->isReward ? 6 : 501,                                       //Como não tem a informação de tipo de transação, seta manualmente
                    'transactionDate'       => Util::getNowWithTimezone($placeData['timezone'], 'Y-m-d H:i:s'), //Como não tem o campo de data de transação, usa a data atual
                    'transactionIDExternal' => $this->transactionNumber,
                    'idCustomer'            => $userData['idEndUser'] ?? null,
                    'idPlace'               => $placeData['idPlace'] ?? null,
                    'customerCode'          => $userData['customerCode'] ?? null,
                    'placeCode'             => $placeData['placeCode'] ?? null,
                    'globalCode'            => $placeData['globalCode'] ?? null
                ]
            ));```

 but I don't know what the ? and to: do

CodePudding user response:

the translation was bad, I need to know what is the purpose of the element "?" and the element ":"

CodePudding user response:

If you're referring to:

'type' => $this->isReward ? 6 : 501

It is called Ternary operator. Is something like "If $this->reward is truly, then 'type' is 6, else 'type' is 501".

See this question.

  •  Tags:  
  • php
  • Related