开发者

Referencing the Compared Variable in PHP

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜