Multi-threading in PHP
You can have multi-threading in PHP by using exec to call a different script and pipe it's output elsewhere. This is basically simulating multi-thread support as PHP itself does not have it and thus it won't have convinent methods and handles to deal with threads.
So for example:
exec('php thread2.php > /dev/null &');Would execute thread2.php in a seperate thread and send output to null. You can of course also pipe outputs to file to exchange data between threads via files. (Probably better to use memory)
You can pass arguments by putting the arguments after the script file name:
exec('php thread2.php 1 test > /dev/null &');In thread2.php you can access the arguments with global variables $argv and $argc.
More details here: http://www.php.net/manual/en/features.commandline.usage.php
Version
Last Updated
First Published
Comments
Any published comments will adhere to the etiquette policy and all e-mail addresses will be treated in accordance to the privacy policy.
Me in real-time
- If you see this, something's wrong with Twitter.
Blatant Plug
Support
I've pledged my support to these organisations, and I think you should too.






