I have copied the below code and on running the code it always shows
parent
as output.But the source file says it will display output as
child
parent
.Please advice me "How to implement threading in PHP".
<?php
if (! function_exists('pcntl_fork')) die('PCNTL functions not available on this PHP installation');
$pid = pcntl_fork();
if($pid) {
echo "parent
";
}
else {
echo "child
";
}
?>
Note:While running in cli getting an error
PHP Warning: Module 'pcntl' already loaded in Unknown on line 0
Source:http://www.electrictoolbox.com/article/php/process-forking/