Your string concat is a bit off, and PHP uses dots .
to concat variables together, not +
like JavaScript.
There are a couple of ways you could achieve this, via a ternary operator
$cartlink = '<a class="cart-contents" href="'.$shoppingcart.'" title="View your shopping cart">'.($count > 0 ? '<span class="cart-contents-count">"'.$count.'"</span></a>' : "").'</a>';
Or string concatination via a normal if
$cartlink = '<a class="cart-contents" href="'.$shoppingcart.'" title="View your shopping cart">';
if ($count > 0)
$cartlink .= '<span class="cart-contents-count">"'.$count.'"</span></a>';
$cartlink .= '</a>';