如何在php中访问pthread的run函数中的全局变量

时间:2016-06-09 11:51:53

标签: php pthreads

我无法在pthread运行函数中全局访问变量,我可以知道该怎么做吗?

class Promise extends Thread
{
    public function __construct()
    {
        global $myVar;
         echo "inside construct function variable " . $myVar;
     }

        public function run()
    {
        global $myVar;
         echo "inside run function variable " . $myVar;
   }
}

我可以在构造中访问myVar全局变量但不能运行函数吗?我能知道为什么吗?

0 个答案:

没有答案