Home > Mobile >  CodeIgniter, call another function after $this- response
CodeIgniter, call another function after $this- response

Time:09-17

I am using Rest library and have the following function as below:-

function post_rayz(){
$one = $this->testone();
if($one == 1){
$this->sendSMS();
}
}  
function testone(){
$this->response(['status' => 1, 'message' => 'success 4'], 200);    
}

function sendSMS(){
echo "two";
}

When i get a response from function testone() the script stops and is not going to sendSMS() function.

I want to sendSMS after successfully complete testone()

Any help will be most welcome. Thanks

CodePudding user response:

You need to change the order of operations or if sending that SMS is time consuming maybe you can add it to a queue and process it later. By calling $this->response() you end the request by sending a response to user.

LE: Have a look on fastcgi_finish_request() to see if you can tweak the framework.

CodePudding user response:

you have to return your response

function testone(){
 return $this->response(['status' => 1, 'message' => 'success 4'], 200);    
}

$one is array , you must check the status

if($one[0]['status'] == 1){
 $this->sendSMS();
}
  • Related