小编use*_*312的帖子

PHP线程SimpleXMLElement

我一直在搜索这个问题而且我遇到了很多问题,但我不认为这是实际代码的问题.基本上这个代码在两个独立的线程中启动套接字服务器(登录和游戏),我基本上从非线程版本转换了这个代码,但我一直无法让这个工作用于线程.

include "socket.php";
include "dep.php";

class Server extends Thread {
    public $server;
    public $config;
    public function __construct($type){
        //$this->config = (string)$type;
        $this->run2($type);
        $this->run();
    }
    public function run(){
        while(true){
            $this->server->loop();
        }
    }
    public function run2($config){
        $this->server = new sokserv($config);
        $this->server->init();
        //while(true){
        //  $this->server->loop();
        //}
    }
}
$login = new Server('Config/config.xml');
$game = new Server("Config/config2.xml");
The error received is 
Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\Users\=\Desktop\Test\Start.php:19
Stack trace:
#0 C:\Users\=\Desktop\Test\Start.php(19): Server->run2()
#1 C:\Users\=\Desktop\Test\Start.php(10): Server->run2('Config/config.x...')
#2 …
Run Code Online (Sandbox Code Playgroud)

php xml multithreading pthreads simplexml

4
推荐指数
1
解决办法
635
查看次数

标签 统计

multithreading ×1

php ×1

pthreads ×1

simplexml ×1

xml ×1