开发者

Referencing the Compared Variable in PHP

开发者 https://www.devze.com 2023-03-27 11:35 出处:网络
This feels like a really stupid question, but I\'ve always wonde开发者_开发百科red if I\'ve been doing this wrong:

This feels like a really stupid question, but I've always wonde开发者_开发百科red if I've been doing this wrong:

if($payment->shipping_state OR $payment->shipping_province)
    {
        $request['SHIPTOSTATE'] = isset($payment->shipping_state) ? $payment->shipping_state : $payment->shipping_province;
    }

Is there a keyword/an easier way to set $request['SHIPTOSTATE']to the variable which exists, since I already confirmed one of the two do in fact exist?

Something like:

if ($payment->shipping_state OR $payment->shipping_province)
{
  $var = $this;
}


$data = (!empty($payment->shipping_state))?$payment->shipping_state:$payment->shipping_province;
if (!empty($data))
    $request['SHIPTOSTATE'] = $data;
0

精彩评论

暂无评论...
验证码 换一张
取 消