Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

UnixReview.com:
PHP Multi-tasks
Sep 26, 2006 @ 12:38:07

From UnixReview.com, there's a handy guide to functionality that PHP supports to help you get a handle on things like multiple socket requests - multi-tasking in PHP.

There's quite a bit more to tell, though, about PHP and concurrency. AJAX certainly boasts multi-tasking capabilities, and PHP supports AJAX about as well as the other Web languages support Ajax. An easy conclusion is that, by way of AJAX, therefore, PHP multi-tasks. However, common security, accessibility, and compatibility requirements prevent use of AJAX in many programs.

It's also true that PHP does not "support threads", as many observers put it. Even without AJAX, even without threads, there are still at least two distinct ways to achieve server-side multi-tasking with PHP. Let's look at how the language multi-tasks, and why:

They give an example of one way to fetch information from multiple sources normally (concurrent socket requests) to provide the "low level". They then show an example of how to use pcntl_fork, pcntl_exec, and streams support that can be built into PHP to create a three process function to grab the main pages (and status codes) from each of the sites in an array.

tagged: multitask pcntl_fork pcntl_exec streams socket http multitask pcntl_fork pcntl_exec streams socket http

Link:

UnixReview.com:
PHP Multi-tasks
Sep 26, 2006 @ 12:38:07

From UnixReview.com, there's a handy guide to functionality that PHP supports to help you get a handle on things like multiple socket requests - multi-tasking in PHP.

There's quite a bit more to tell, though, about PHP and concurrency. AJAX certainly boasts multi-tasking capabilities, and PHP supports AJAX about as well as the other Web languages support Ajax. An easy conclusion is that, by way of AJAX, therefore, PHP multi-tasks. However, common security, accessibility, and compatibility requirements prevent use of AJAX in many programs.

It's also true that PHP does not "support threads", as many observers put it. Even without AJAX, even without threads, there are still at least two distinct ways to achieve server-side multi-tasking with PHP. Let's look at how the language multi-tasks, and why:

They give an example of one way to fetch information from multiple sources normally (concurrent socket requests) to provide the "low level". They then show an example of how to use pcntl_fork, pcntl_exec, and streams support that can be built into PHP to create a three process function to grab the main pages (and status codes) from each of the sites in an array.

tagged: multitask pcntl_fork pcntl_exec streams socket http multitask pcntl_fork pcntl_exec streams socket http

Link:


Trending Topics: