title: Callback for cURL in PHP
body: <p>I have a Single Sign On system that requires communication between 2 servers. The child server send something to the parent server to validate, it it's valid, then register the user, if not, send back the error message, say "email exist in database already", etc.</p>
  
  <p>I'm wondering that is there any way that I can do this in cURL?</p>
  
  <p>So the child can send a validation request like:</p>
  
  <blockquote>
  <pre><code>              $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //this prevent printing the 200json code
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); //timeout 1s
                curl_setopt($ch, CURLOPT_TIMEOUT, 3); //timeout 1s
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                $result = curl_exec($ch);
                curl_close($ch);
  </code></pre>
  </blockquote>
  
  <p>It seems that <strong>"$result = curl_exec($ch);"</strong> is the result(callback). It's simply 200 now. Is there a way I can pass the validation error/success via this or via other params of curl like a callback? How should I write the code in parent server(who is getting curled and going to send the response back)? Should I just do "<strong>echo $error;</strong>" to return the result to the child?</p>