企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[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`