🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## demo index.php ``` function isWindow(){ return substr(php_uname(), 0, 7) == "Windows"; } function execInBackground($cmd) { if (isWindow()){ pclose(popen("start /B ". $cmd, "r")); } else { exec($cmd . " > /dev/null &"); } } $cmd = "/usr/bin/php client.php"; // or php client.php execInBackground($cmd); ?> <p>success </p> ``` client.php ``` $redis = new Redis(); if ( ! $redis->connect('127.0.0.1', 6379)) { print_r($redis->getLastError()); } $i=0; while (true){ $i++; //code //$redis->publish("chat", $i); //redis 发布 ,用 SUBSCRIBE chat 接受 sleep(1); } ``` 执行 `curl http://127.0.0.1:8080/index.php`