title: cURL operation and PHP
body: <p>I have a frontend code </p>
  
  <pre><code>$ch = curl_init();
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
  curl_setopt($ch, CURLOPT_URL, $url);
  //make the request
  $responseJSON = curl_exec($ch);
  $response_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);
  
  if ($response_status == 200) { // success
      // remove any "problematic" characters from the json string and then decode
      if (debug) {
          echo "----finish API of getAPI inside basic_function with status==200---";
          echo "&lt;br&gt;";
          echo "-------the json response is-------" ;  //.$responseJSON;
          var_dump($responseJSON);
          //print_r($responseJSON);
          echo "&lt;br&gt;";
      }
      return json_decode( preg_replace( '/[\x00-\x1F\x80-\xFF]/', '', $responseJSON ) );
  }
  </code></pre>
  
  <p>and I have a backend code which executed when cURL fired its operation with its URL. The backend code would therefore activated. So, I know cURL is operating.</p>
  
  <pre><code>$output=array (
    'status'=&gt;'OK',
    'data'=&gt;'12345'
  )
  
  $output=json_encode($output)
  
  echo $output;
  </code></pre>
  
  <p>and <code>$output</code> shown on browser as <code>{"status":"OK","data":"12345"}</code></p>
  
  <p>However, I gone back to the frontend code and did <code>echo $responseJSON</code>, I got nothing. I thought the output of <code>{"status":"OK","data":"12345"}</code> would gone to the <code>$responseJSON</code>. any idea?</p>
  
  <p>Here's output on Browser, something is very odd!  the response_status got 200 which is success even before the parsing of API by the backend code. I expect status =200 and json response after the {"status":"OK","data":"12345"}</p>
  
  <p>=========================================================================================</p>
  
  <p>inside the get API of the basic functions</p>
  
  <pre><code>-------url of cURL is -----http://localhost/test/api/session/login/?device_duid=website&amp;UserName=joe&amp;Password=1234&amp;Submit=Submit
  
  
  
  ----finish API of getAPI inside basic_function with status==200---
  -------the json response is-------string(1153) 
  
  
  "************inside Backend API.php******************
  
  ---command of api is--/session/login/
  
  
  ---first element of api is--UserName=joe
  
  --second element of api is---Password=1234
  
  ---third element of api is----Submit=Submit
  
  ----fourth element of api is---
  
  -------inside session login of api-------------
  
  {"status":"OK","data":"12345"}
  </code></pre>