title: php code for a response to a curl post request
body: <p>I am new to cURL and I am setting up a test environment to send a cURL POST request using PHP and then I need to mimic the server (responding) program (PHP also) with a status code and payload. After looking and reading up on cURL and corresponding documentation and pertinent RFC documents there are a lot of examples on the request side but I could find no pertinent examples for the response side. My request code is as follows:</p>
  
  <pre><code>$url = 'http://localhost/curlresponder.php';  
                $fields =  array(
                     'City'            =&gt; urlencode('Hokeywaka'),
                     'State'           =&gt; urlencode('IL'),
                     'Zip'             =&gt; urlencode('60677'),
                );
                foreach($fields as $key =&gt; $value)
                       {$fields_string .= $key . "=" . $value . '&amp;';}
                       rtrim($fields_string, '&amp;');
  
                $ch = curl_init();
  
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_POST, TRUE);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  
                $result = curl_exec($ch);
  
                curl_close($ch);
                if  ($result === FALSE)
                    {echo 'Return failure ' . '&lt;br /&gt;';
                else
                    {Process $result;}
  </code></pre>
  
  <p>Now I need to know what the responding program code is - assuming the request is received and processed successfully the response code of 200 is to be sent back with a payload attached (which I gather is also POST since the request was POST.</p>