Lineke Kerckhoffs-Willems has posted a good tutorial over on the IBuildings blog titled Multithreading in PHP with CURL. It’s a short read with some proof-of-concept code but worth taking a look at if you’ve ever wondered how to simulate multi-threaded processing with PHP.
Besides using curl for getting the content of other websites, it is also possible to use curl for multithreading in PHP. PHP has no native support for multithreading like Java. Each PHP request is a separate thread. There are some workarounds like using pcntl_fork, starting multiple commandline PHP processes using the exec command or even using ajax. Another possibility is using the Curl library.
It’s pretty light on the WHY but it makes up for it with the HOW. If you like articles that are generously sprinkled with example code, you are going to love this one.


Comments (Login to leave comments)