Use the swoole_http_response method header, status, and end to redirect the code as follows {code ...} however, after redirect () is used, the program is not interrupted and continues to be executed. later, I throw an exception to interrupt the program and won't let him continue executing it later. However, this... use the swoole_http_response method header, status, and end to redirect
The code is as follows:
public function redirect($url) { $this->header("Location", $url); $this->status(302); return $this->end(''); }
However, after redirect () is used, the program is not interrupted and continues to be executed,
Later, I used an Exception thrown to interrupt the program and prevent him from executing it later. However, this method causes worker to restart,
Problem:Is there a good way to do this? after a page jump, the program will be interrupted immediately and it will not continue to be executed. Will the page jump immediately? Do not use methods that throw exceptions to interrupt the program
Reply content:
Use the swoole_http_response method header, status, and end to redirect
The code is as follows:
public function redirect($url) { $this->header("Location", $url); $this->status(302); return $this->end(''); }
However, after redirect () is used, the program is not interrupted and continues to be executed,
Later, I used an Exception thrown to interrupt the program and prevent him from executing it later. However, this method causes worker to restart,
Problem:Is there a good way to do this? after a page jump, the program will be interrupted immediately and it will not continue to be executed. Will the page jump immediately? Do not use methods that throw exceptions to interrupt the program
I would like to say that exit (0) is a bit wrong.
Swoole has never been used. I read swoole's document just now,
Swoole_http_response-> end
Send the Http response body and end request processing.
Swoole_http_response-> end (string $ html );
After the end operation, the system sends HTML content to the client browser and destroys the $ request/$ response object.
If KeepAlive is enabled, the connection is retained, and the server waits for the next request.
KeepAlive is not enabled, and the server will disconnect
$ Response object is destroyed after end (). the http response is complete and the business code will not be executed.
Http://wiki.swoole.com/wiki/p...
It can be understood that the reactor is nginx, and the worker is php-fpm. The reactor thread processes network requests asynchronously and concurrently, and then forwards the requests to> worker processes for processing. Reactor and worker communicate with each other through IPC.
Swoole's reactor, worker, and task_worker can be closely integrated to provide more advanced usage methods.
In a more common analogy, assume that the Server is a factory, and the reactor is sales, helping you pick up project orders. While worker is a worker. after sales and sales are received, worker will work to produce what the customer wants. Task_worker can be understood as an administrative staff who can help the worker to do more complex tasks, so that the worker can concentrate on its work.
It seems that the woker restart has no effect.