/PHPThreads

Simple multithreading in PHP

Primary LanguagePHPApache License 2.0Apache-2.0

PHP Threads, PHP 5.3+

This class makes it easy to implement multithreading in PHP.
It works on any hosting, the only requirement is curl.
by Andrzej Wielski


Including the class

`require_once 'lib/Threads.php';`

Creating a Thread

$Thread->Create(function(){
sleep(5);
echo 'Sleep 5';
});

Starting Threads

$Thread->Run();


Starting Threads without printing anything from thread

`$Thread->Run(false);` This code will run, but nothing will shown for user.
`print_r($Thread->Run(false));` This code will run, and we get only responses from threads (return).

Transfer variables to the thread

$Thread->Create(function($vars) use ($a){
 echo $a;
});

This code will print $a


Security

You should change password and salt in file "lib/Threads.php"
`private $password = '785tghjguigu'; private $salt = 'DfEQn8*#^2n!9jErF';`
This is the password for encrypting the functions

Download