Simple PHP question

I have this little snippet of code:


$writer->startElement('ShippingMethod');	
$writer->text($shipping_method);				
$writer->endElement();

I want to make it so that if the Shipping Method is “USPS-FCM” what gets written out is “USPS-FCM-DC”, otherwise if it’s anything else, whatever was passed in as the shipping method should get written out. Basically I’m trying to add an if, then, else statement. I tried the below, but I must have the syntax wrong. Can anyone help? Thanks.


$writer->startElement('ShippingMethod');
if ($shipping_method='USPS-FCM');
  {
  $writer->text('USPS-FCM-DC');;
  }
else
  {
  $writer->text($shipping_method);
  }	
$writer->endElement();

= != ==

That’s cute!

aaelghat, you’ve also got one additional issue besides the above. Your ‘if’ statement has a semicolon after it. It needs to be removed. I’m surprised the interpreter didn’t complain about a misplaced ‘else’.

friedo and core_dump - thanks a lot.

My interpreter is the “notepad” like editor in WinSCP. The code works now - thanks much!

Also, one of your lines has two semicolons at the end, though it’s harmless at the moment.