💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ## 实战 demo(带有演示输出) > 通过输出 script 的方式进行美化输出 核心代码 ``` function sp_show_msg($msg){ echo sprintf("<script type='application/javascript'>show_msg('%s')</script>",$msg); flush(); ob_flush(); } ``` <details> <summary>描述</summary> ``` function sp_show_msg($msg){ echo sprintf("<script type='application/javascript'>show_msg('%s')</script>",$msg); sleep(1); flush(); ob_flush(); } echo <<<EOF <!doctype html> <html lang="en"> <head> <style> li{list-style: none} </style> </head> <body> <div>上</div> <div> <p>消息输出</p> <ul class="log"> </ul> </div> <div>下</div> <script> function show_msg(msg) { var log = window.document.querySelector(".log"); var li = window.document.createElement("li"); li.innerText=msg log.appendChild(li) } </script> </body> </html> EOF; flush(); ob_flush(); for($i=0; $i < 4; $i++){ sp_show_msg("output:".$i); } ``` </details> <br/>