title: Warning issued upon moving site files to PHP7 server
body: <p>My site has a checkout which gives the following warnings together on a white page after submitting a test purchase.</p>
  
  <blockquote>
    <p>Warning: Creating default object from empty value in wordpress.php on line 1460<br>
    Warning: Cannot modify header information - headers already sent by (output started at wordpress.php on line 1842</p>
  </blockquote>
  
  <p>Line 1460 refers to the following: <code>$totals-&gt;quantity = $total_qty;</code></p>
  
  <p>This is a part of the code: </p>
  
  <pre><code>if (!function_exists('yak_get_totals')) {
      /**
       * Return an array containing the total quantity and total price of an array of items.
       */
      function yak_get_totals(&amp;$items) {
          $total_qty = 0;
          $total_price = 0;
          foreach ($items as $key=&gt;$item) {
              if (!isset($item-&gt;price)) {
                  $item-&gt;price = yak_calc_price($item-&gt;id, $item-&gt;cat_id, $item-&gt;price);
              }
              $total_qty += $item-&gt;quantity;
              $total_price += ($item-&gt;price * $item-&gt;quantity);
          }
          $totals-&gt;quantity = $total_qty;
          $totals-&gt;price = $total_price;
          return $totals;
      }
  }
  </code></pre>
  
  <p>This code is a part of a plugin I have been using on WordPress for a number of years. The developer of the plugin discontinued it so now with a change of servers I am trying to update the code to work in PHP7. </p>
  
  <p>On the back-end the plugin is working as it should. It sends out an email indicating the sale was made and the purchase shows up in the order area etc. However, a customer doesn't get to the order confirmation page they instead get this page.</p>