Hướng dẫn can php run asynchronously?

How can I run PHP code asynchronously without waiting? I have a long run [almost infinite] that should run while server starts and should process asynchronously without waiting.

Nội dung chính

  • Not the answer you're looking for? Browse other questions tagged php or ask your own question.
  • Can PHP run asynchronously?
  • Is PHP synchronous or asynchronous?
  • How do I run a PHP script?
  • How do I run a PHP script from the command line?

The possible options I guess are:

  1. Running the code in a web page and keep it open to do that task
  2. Calling the script from some command line utility [I am not sure how] which would process in the background.

I am running the PHP scripts on my local server which will send emails when certain events occur, e.g. birthday reminders.

Please suggest how can I achieve this without opening the page in a browser.

asked May 6, 2011 at 1:20

6

If you wanted to run it from the browser [perhaps you're not familiar with the command line] you could still do it. I researched many solutions for this a few months ago and the most reliable and simplest to implement was the following from How to post an asynchronous HTTP request in PHP

Chủ Đề