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;
精彩评论