I suppose this is a specific question, but for some reason, when I create a Thread like this:
require_once(__DIR__.'/myotherfile.php');
class StreamBufferInput extends Thread {
public function run(){
global $max_buffer_size;
global $data_source;
echo "DATA:" . $max_buffer_size;
...
}
}
myotherfile.php
has those two variables declared in it (and they can be accessed from other classes, but my echo
statement here prints DATA:
and nothing else. I couldn't find much on doing global variables within classes, but I have a global declaration like this in a function of one of my other classes, and it works fine.
EDIT: Here is how I'm starting the Thread.
$stream = new StreamBufferInput();
$stream->start();