Use the Swoole_http_response method header,status,end to implement a jump
The code is as follows
public function redirect($url) { $this->header("Location", $url); $this->status(302); return $this->end(''); }
But after using redirect (), the program is not interrupted, or continues to execute,
Then I broke the program with an exception and didn't let him go back, but this method caused the worker to restart,
question: There is no good way, after the page jump, the program immediately interrupted, will not continue to execute, the page immediately jump? Requires a method that does not use throwing exceptions to interrupt the program
Reply content:
Use the Swoole_http_response method header,status,end to implement a jump
The code is as follows
public function redirect($url) { $this->header("Location", $url); $this->status(302); return $this->end(''); }
But after using redirect (), the program is not interrupted, or continues to execute,
Then I broke the program with an exception and didn't let him go back, but this method caused the worker to restart,
question: There is no good way, after the page jump, the program immediately interrupted, will not continue to execute, the page immediately jump? Requires a method that does not use throwing exceptions to interrupt the program
I was going to say exit (0), it feels a little wrong.
Didn't use Swoole, just looked at the Swoole document,
Swoole_http_response->end
Sends the HTTP response body and ends the request processing.
Swoole_http_response->end (string $html);
The end action sends HTML content to the client browser and destroys the $request/$response object
If KeepAlive is turned on, the connection will remain and the server will wait for the next request
If KeepAlive is not turned on, the server will disconnect
End () After the $response object is destroyed, the HTTP response is complete, and the business code should not be executed.
Http://wiki.swoole.com/wiki/p ...
Can be understood as reactor is Nginx,worker is PHP-FPM. The reactor thread asynchronously processes the network request in parallel and then forwards it to the >worker process to process it. Communication between the reactor and the worker through the IPC method.
Swoole Reactor,worker,task_worker can be tightly combined to provide a more advanced way of use.
A more popular metaphor, assuming that the server is a factory, that reactor is sales, to help you get the project order. The worker is the worker, when sells > sells the order, the worker goes to work to produce the customer wants the thing. And Task_worker can be understood as the administrative staff, can help the worker to do some miscellaneous >, let the worker concentrate on work.
Woker reboot doesn't seem to have any effect.