# Simple PHP question

**URL:** <https://boards.straightdope.com/t/simple-php-question/635437>\
**Category:** Factual Questions\
**Created:** [September 21, 2012, 9:36pm UTC](https://boards.straightdope.com/t/simple-php-question/635437 "2012-09-21T21:36:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaelghat](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@aaelghat](https://boards.straightdope.com/u/aaelghat)\
**Post date:** [September 21, 2012, 9:36pm UTC](https://boards.straightdope.com/t/simple-php-question/635437/1 "2012-09-21T21:36:10Z")

</div>

I have this little snippet of code:

```auto

$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.

```auto

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

```

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [September 21, 2012, 9:37pm UTC](https://boards.straightdope.com/t/simple-php-question/635437/2 "2012-09-21T21:37:50Z")

</div>

= != ==

---

<div class="post-metadata">

**Author:** ![core\_dump](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@core\_dump](https://boards.straightdope.com/u/core_dump)\
**Post date:** [September 21, 2012, 10:05pm UTC](https://boards.straightdope.com/t/simple-php-question/635437/3 "2012-09-21T22:05:39Z")

</div>

> [@friedo](#):
>
> = != ==

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’.

---

<div class="post-metadata">

**Author:** ![aaelghat](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@aaelghat](https://boards.straightdope.com/u/aaelghat)\
**Post date:** [September 21, 2012, 10:20pm UTC](https://boards.straightdope.com/t/simple-php-question/635437/4 "2012-09-21T22:20:52Z")

</div>

friedo and core\_dump - thanks a lot.

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

---

<div class="post-metadata">

**Author:** ![Space\_Vegetable](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Space\_Vegetable](https://boards.straightdope.com/u/Space_Vegetable)\
**Post date:** [September 21, 2012, 11:37pm UTC](https://boards.straightdope.com/t/simple-php-question/635437/5 "2012-09-21T23:37:24Z")

</div>

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