2014-04-07 15:58
浏览 368


I'm trying to figure out if it is possible to do the following using php:

I have a website that uses php to display database information. Now, I'd like to be able to implement another capability and that is I'd like to write a new php web page and launch a thread which executes a binary and have the output be displayed on the web page live (if possible).

I think I need to use ajax to be able to refresh the page in order to show "live output" in the page.

The problem I'm having is figuring out if I can launch a thread that executes a binary and display the output on the webpage. Is that possible? If so, how?

图片转代码服务由CSDN问答提供 功能建议


我有一个使用php显示数据库信息的网站。 现在, 我希望能够实现另一个功能,那就是我想编写一个新的php网页并启动一个执行二进制文件的线程并将输出显示在网页上(如果可能的话) )。

\ n

我遇到的问题是弄清楚我是否可以启动执行二进制文件的线程并在网页上显示输出。 那可能吗? 如果是这样,怎么样?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dpjtn48868 2014-04-07 21:06

    You can do like this, use jquery plugin, to do ajax and load result of script.php to any section of your html page.


         echo exec('date'); //type command to be executed here.


        <script type="text/javascript" src="" >
        <script type="text/javascript">
        function executeScript(){
        <div id="result"> command result will come here.. </div>

    It will call script.php at every second and its result will be shown in <div id="result"> </div>

    You can also use jQuery ajax .post(), .get() or .ajax() to pass some argument to script and get response accordingly.

    点赞 评论
  • douchuanhan8384 2014-04-07 16:06

    The way to do this kind of thing is usually to execute the binary and disown it but have its output written to a file as it runs.

    Then your ajax system literally downloads that text file for display.

    点赞 评论

相关推荐 更多相似问题