title: Why is this php code displaying json array without code to display it?
body: <pre><code>&lt;?php
  
  function pay()
  {
          $data = '
      {
            "intent":"sale",
  
            "redirect_urls":
            {
              "return_url":"http://n1.lchs-is.org",
              "cancel_url":"http://n1.lchs-is.org"
            },
  
            "payer":
            {
              "payment_method":"paypal"
            },
  
            "transactions":
            [
              {
                "amount":
                {
                  "total":"7.47",
                  "currency":"USD"
                },
  
                "description":"This is the payment transaction description."
              }
            ]
      }
          ';
  
  
      //Start curl request
      $ch = curl_init();
  
      //Set curl options
      curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payment");
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  
      curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            "Content-Type: application/json",
            "Authorization: Bearer A101.lTxNCRX3B-vhQIN4991wdthA6SzCtPKganKXVOZta84hADs-25S5OGk4yyG-HLzR.lM-rDOIJAaEXGWhcYi2YF8yhnRy",
          ));
  
      //Display results
      $json = curl_exec($ch); // &lt;------- It's displaying this array that it receives from curl right here
      curl_close($ch);
  }
  pay();
  
  ?&gt;
  </code></pre>
  
  <p>I coded this PHP code to simply create a paypal payment, and when I run it, it displays the JSON Array, even when I coded it not to. Why is this so and how can I fix this?</p>
  
  <p>Also any code I typed after executing the <code>pay()</code> function, is not executed. For example if I put <code>echo "test";</code> that line of code is not executed.</p>