Search code examples
phpcodeignitercurlphp-curl

PHP "echo" not working before curl function



  funtion request(){

  echo "Success";

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_TIMEOUT, $request_timeout);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $request_timeout);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $response = curl_exec($ch);
  $curl_error = curl_errno($ch);
  $getserver = curl_getinfo($ch);
  curl_close($ch);
}

here success echo only shows after exicuting curl function . i wanna echo the success message before curl function calls.


Solution

  • If this code is in the controller and you are calling from a different function in the same file, you need to call $this->request(), let me convey this information.

    Later,

    maybe you can return a result with return "Success";