I'm attempting to have a php script run multi-threaded using PHP pThreads in a IIS 7 PHP 5.6 x86 (thread safe) environment. I've created a github issue but I haven't heard back and though some other coders here may have experienced the same problem.
PHP is running fine and scripts which don't require pThreads execute like normal. However when I add some multi-threaded code to my script, only the block of code which is non-multithreaded executes in the browser unless I call phpinfo before executing the code. For example:
<?php
class AsyncOperation extends Thread {
public function run(){
echo 'hello world';
}
}
$thread = new AsyncOperation();
if($thread->start()) {
$thread->join();
}
?>
Has no output in the browser (still a response code of 200 though).
But the following code with phpinfo called first works:
<?php
phpinfo();
class AsyncOperation extends Thread {
public function run(){
echo 'hello world';
}
}
$thread = new AsyncOperation();
if($thread->start()) {
$thread->join();
}
?>
The expected output of all of the phpinfo content, and then hello world is there. I've also noticed that sending phpinfo(64)
does not echo hello world, but all of the other valid parameters for phpinfo cause hello world to be printed.
I've also tried running the original (without phpinfo) script from the command line and noticed that "hello world" is echoed in the console. Which leads me to believe this is an IIS7 misconfiguration but that doesn't explain how calling phpinfo would make it work?
Also I should note, there's nothing in the error logs either, and the system is set to log all errors.